בעיות תווים עם קידוד שאינו UTF בכתובות URL

סיכום מבוסס בינה מלאכותית

The discussion revolves around handling non-UTF-8 accented characters in URLs during a Spanish forum migration. RGJ explains that permalinks with ISO 8859-15 encoded characters (e.g., Galer%EDa-de-im%E1genes) cause a server error due to invalid UTF-8 sequences, while properly encoded UTF-8 URLs (e.g., Galeria-de-imagenes) result in a “not found” page. gerhard suggests decoding the ISO 8859-15 characters to UTF-8 before generating permalinks as a potential solution, but notes the complexity and lack of an easy fix. RGJ confirms that over 150,000 external links rely on the legacy encoded URLs, making a workaround necessary.

We’re migrating a Spanish forum and setting up permalinks for all topics.
The existing titles and URL’s have accented characters in ISO 8859-15 in them, escaped with percent encoding

forum/showthread.php?96700-Galer%EDa-de-im%E1genes

We’re rewriting them with /forum\/showthread.php\?(\d*).*/thread/\1 but unfortunately we get a server error (with a white page) before the permalink normalization is processed.

You can see this on for instance Try:

https://try.discourse.org/forum/showthread.php?96700-Galer�a-de-im�genes gives a blank page and “bad request”. Rack::QueryParser::InvalidParameterError (invalid byte sequence in UTF-8)

https://try.discourse.org/forum/showthread.php?96700-Galeria-de-imagenes gives the regular “not found” page.

Do you have any tips on how to get around this without too much bespoke nginx tweaking?

Maybe decoding 96700-Galer%EDa-de-im%E1genes as ISO 8859-15 and encoding it as UTF-8 before generating the permalink is a solution? Or are there actually incoming links out there that use the ISO 8859-15 encoded characters in the URL?

Mind, I’m not sure if it’s even necessary to use percent encoding for permalinks to work – I haven’t looked at the code. I guess you’ll need to experiment a little bit. I don’t think there’s an easy solution for this. If you find a solution, please post it here. It might be helpful for others.

Yes, there are about 150,000 external links that we have no control over.