Coder Social home page Coder Social logo

Comments (11)

Flameborn avatar Flameborn commented on September 26, 2024 1

Thanks. It seems that wakautils.pl in this case is not imported by kiramoji.pl, at least when generating the feed.

Since wakautils.pl does not use 99.99% of the config variables, I've opted to add a $protocol variable instead. By default, it's set as http, but changing it to https should generate proper links now.

Please reopen if it still doesn't work.

from kiramoji.

Flameborn avatar Flameborn commented on September 26, 2024

This might depend on the used web server.

Our instance uses https, and the RSS feed does not include a port number.

Links are generated using http in the feed, but the server redirects to the https protocol instead. This is possibly something that needs to be looked into in the future.

What steps did you take to produce these malformed links?

from kiramoji.

dewheel avatar dewheel commented on September 26, 2024

The environment is as follows:

Ubuntu 22.04 LTS
Apache v2.4.52
perl v5.34.0
Kiramoji v3.2

Spin up an instance of Kiramoji in the above environment in message mode and configure Apache2 to redirect all traffic to https, that should reproduce the issue. You're running Caddy in your instance, correct?

For the instance I'm having trouble with Apache2 is configured to redirect all http request to https with mod_rewrite, which may have caused the issue to surface. Aside from a hacky edit of wakautils.pl to resolve the issue (as I've done), I believe tweaking mod_rewrite to redirect http://example.com:443 URLs to https://example.com may also resolve the issue in the interim.

from kiramoji.

Flameborn avatar Flameborn commented on September 26, 2024

Thanks for posting your environment.

I think the problem is that Apache provides a few things as environment variables that Caddy doesn't, which is likely the reason why it works here.

By default, Caddy tries to redirect http connections to https, and while Apache does the same, it also provides, I believe, a port number as an environment variable, which throws browsers off.

Adding native HTTPS support is something I would need to research, ideally with LetsEncrypt.

For now, I could add a protocol variable to the configuration file, defaulting to HTTP, which would take over the hardcoded protocol values for $absolute_self and $absolute_path. This would still add the port number to the URL, which we could ignore if set to 80 or 443. I'm not sure if this is the best solution though, as I would personally do this via the used web server. But then again, getting rid of hard-coded values is always a good idea.

I'm definitely open to ideas ☺️

from kiramoji.

dewheel avatar dewheel commented on September 26, 2024

Thanks for posting your environment.

Of course, please let me know if you require any more info regarding my implementation.

A protocol variable would be a good way to resolve this, that or determining the protocol programmatically if possible (well beyond my depth). I would also be partial to dropping $port entirely from $absolute_self and $absolute_path, but this would cause issues for site owners who use non-standard ports (I think they still exist). On the other hand, if Caddy doesn’t provide a port number at all and still works as intended then maybe $port can be removed after all. A hardcoded HTTP link without a declared port would still work on any site that redirects HTTP traffic to HTTPS.

from kiramoji.

Flameborn avatar Flameborn commented on September 26, 2024

I've added a PROTOCOL config variable. The port number, if 443, should not be part of the generated URLs as well, similarly to how port 80 behaves. You can find this at https://github.com/Flameborn/Kiramoji/tree/FixMalformedURLs

Could you please test these changes and see if they fix the issue for you?

In config.pl, uncomment line 68, which should set the protocol to https for the generated URLs.

from kiramoji.

dewheel avatar dewheel commented on September 26, 2024

I just tested your changes and unfortunately that did not resolve the issue. Links in the RSS fee are now formatted as follows (note the missing protocol):

<link>://example.com/kiramoji/index.html</link>
<link>://example.com/kiramoji/kiramoji.pl/12345/</link>

Does wakautils.pl reference the configuration files? It appears the PROTOCOL variable it's referencing is empty. Furthermore I didn't see the following at the top of wakautils.pl

BEGIN { require 'config.pl'; }
BEGIN { require 'config_defaults.pl'; }

from kiramoji.

Flameborn avatar Flameborn commented on September 26, 2024

from kiramoji.

dewheel avatar dewheel commented on September 26, 2024

I gave it another go, unfortunately that got us a little farther off the mark, here's how the RSS is now formatted:

<link>PROTOCOL://example.com/kiramoji/index.html</link>

from kiramoji.

dewheel avatar dewheel commented on September 26, 2024

Worked as expected, thank you for your assistance!

from kiramoji.

Flameborn avatar Flameborn commented on September 26, 2024

from kiramoji.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.