Problem/Motivation
If Entity Mesh founds a link like this:
https://mysite.com/url-with-diacritical-mark-ó
It displays it as:
https://mysite.com/url-with-diacritical-mark-ó
And it thinks the link is broken because the URL return 404.
Although it is not recommended to have such URLs, they are still valid if they are url encoded (so ó is turned into %C3%B3). Browsers admit typing URLs with chars like ó (although I guess under the hood they url encode them before doing the actual request).
Steps to reproduce
Create a content that points to an URL with special characters like óíáéí, for example. One way is to have a file field with transliteration disabled and upload a file with this characters in its filename.
Proposed resolution
It seems at some point Xray processes the links somehow, converting the special chars in other chars. We should change this, probably url-encoding the links before the processes that alters the char.
Remaining tasks
Find the root cause.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | Screenshot_20250929_130305.png | 12.21 KB | tunic |
| #7 | fixed.png | 151.39 KB | divya.sejekan |
| #7 | beforeFixes.png | 170.29 KB | divya.sejekan |
Issue fork entity_mesh-3549181
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lpeidro commentedComment #3
lpeidro commentedOne of the issues with the URL "https://mysite.com/url-with-diacritical-mark-ó
" occurred during HTML parsing.
It is necessary to set the correct encoding at this stage to ensure that URLs are parsed correctly.
Comment #5
lpeidro commentedThe other issue we identified is related to URLs containing the "+" symbol.
We were previously using the PHP function urldecode, which converts "+" into spaces. As a result, when attempting to retrieve the entity file using the URL, the passed URL was altered.
We have now replaced urldecode with rawurldecode, which does not convert "+" symbols into spaces.
Comment #6
lpeidro commentedIt is ready for review.
Thank you.
Comment #7
divya.sejekan commentedApplied MR!47 , The issue looks fixed now the urls are displayed correctly now. I tried feew of the URLs like
https://es.wikipedia.org/wiki/Canción
https://pt.wikipedia.org/wiki/João
https://fr.wikipedia.org/wiki/Économie
https://is.wikipedia.org/wiki/Ísland
https://cs.wikipedia.org/wiki/Česká_republika
Steps :
- Install Entity Mesh
- Add special character URLs in Node body
- Run the entity mesh
- Check the entity mesh reports /admin/reports/entity-mesh/table
RTBC++
Comment #8
tunicI've tested it on the site I originally detected the problem and it works better but still not perfect. It went from 155 broken links to only 27. Some that are detected as broken links are not broken links. Fo example, this one:
Now, as you can see, the URL is correct (formaci%C3%B3n, urldecoded, is formación), but Entity Mesh still detects it as broken. The URL works ok if you paste it in the browser or click the link in the page.
The link is on WYSIWYG field; I guess this is not relevant, but I drop it here just in case it is.
Comment #9
lpeidro commentedHello Tunic,
I have applied a fix to handle the issue across all URLs, not just in the files.
Additionally, I have added a PHP Unit test to ensure the implementation works correctly.
It is now ready for testing.
Thank you.
Comment #10
lpeidro commentedComment #11
lpeidro commentedI merge the funcionality, it works as expected.