Bug #62307
closedRteFileLinksUpdateWizard.php only handles spaces, no other 'special' characters
0%
Description
This is related, but not the same as Bug #58898. This change fixes an error that goes like <<... not found in referenced element (uid: ...). Reference index was probably out of date.>>
I have a rather big and fairly old instance and some file-links to files with umlauts / accents in my RTE Content. The filename part has apparently been rawurlencoded.
I can reproduce this in 4.7.19 by just linking a text in RTE to a file with umlaut, blockquote or accented character. The result looks like this:
example content 1: ...<link fileadmin/www/bla/Aktionen/file%5B1%5D.pdf>linked text</link>...
example content 2: ...<link fileadmin/bla/blub/pdf/Medien/2010/20100205%20Artikel%20-%20Verkehrsl%C3%A4rm%20hilft%20Steuern%20zu%20sparen%20-%20Landbote.pdf _blank><br>Verkehrslärm hilft Steuern zu sparen</link>......
I tested this with and without the config setting
[SYS][UTF8filesystem] = 1
[SYS][systemLocale] = de_CH
[SYS][systemLocale] = de_CH.utf8
The links that are generated as in example 1 and 2 work fine in 4.7.19 and in 6.2.5.
However, in the Install Tool, while migrating to FAL, the Upgrade Wizard fails in RteFileLinksUpdateWizard.php
fileadmin/www/bla/Aktionen/file[1].pdf not found in referenced element (uid: 8865 of table tt_content in field bodytext). Reference index was probably out of date.
Reason: The regex built in typo3/sysext/install/Classes/Updates/RteFileLinksUpdateWizard.php only handles spaces, no other special characters:
$regularExpression = '$<((link|LINK) ' . str_replace(' ', '%20', $reference['ref_string']) . ').*>$';
If I change the file part of the regex by its rawurlencoded value, then the migration works fine and the links get rewritten and work.
A little catch: $reference['ref_string'] contains the entire path, so rawurlencode also translates slashes to %2F. This can be handled the way we handled whitespace before, str_replacing it back.
Change at Line 1971: old, 2: rawurlencode:
1 $regularExpression = '$<((link|LINK) ' . str_replace(' ', '%20', $reference['ref_string']) . ').*>$';
2 $regularExpression = '$<((link|LINK) ' . str_replace('%2F', '/', rawurlencode($reference['ref_string'])) . ').*>$';
This creates these expressions:
expression 1: $<((link|LINK) fileadmin/www/bla/Aktionen/file[1].pdf).*>$
expression 2: $<((link|LINK) fileadmin/www/bla/Aktionen/file%5B1%5D.pdf).*>$
expression 1:
$<((link|LINK) fileadmin/bla/blub/pdf/Medien/2010/20100205%20Artikel%20-%20Verkehrslärm%20hilft%20Steuern%20zu%20sparen%20-%20Landbote.pdf).*>$
expression 2:
$<((link|LINK) fileadmin/bla/blub/pdf/Medien/2010/20100205%20Artikel%20-%20Verkehrsl%C3%A4rm%20hilft%20Steuern%20zu%20sparen%20-%20Landbote.pdf).*>$
After that, using expression 2, the Upgrade Wizard works fine for me.
Files
Updated by Joachim no-lastname-given almost 10 years ago
- File patch_62307.diff patch_62307.diff added
a minipatch for that...
Updated by Helmut Hummel almost 10 years ago
- Status changed from New to Closed
Thanks for the patch. I can confirm that it solves the issue.
Can you push a change request to our review system? (see: http://wiki.typo3.org/Contribution_Walkthrough_Tutorials)
Please reference #59133 in the commit message, as I'm going to close this as duplicate.
Thanks a lot!