Issue Bug Closed

#62307RteFileLinksUpdateWizard.php only handles spaces, no other 'special' characters

Joachim no-lastname-given 10/17/14, 14:26 updated 10/24/14, 10:23

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>linked text…

example content 2: …<link fileadmin bla blub pdf medien _blank>
Verkehrslärm hilft Steuern zu sparen……

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 197
@1: 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/file1.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.

Reviews 2