Skip to content

Commit fa336e6

Browse files
committed
[6.0] Fix emailToPunycode() throws "Prohibited input U+0000005C" with backslash before quote
Resolves #46356
1 parent 961dd0c commit fa336e6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libraries/src/Filter/InputFilter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ public function clean($source, $type = 'string')
147147
*/
148148
public function emailToPunycode($text)
149149
{
150-
$pattern = '/(("mailto:)+[\w\.\-\+]+\@[^"?]+\.+[^."?]+("|\?))/';
150+
$pattern = '/("mailto:)([\w.\-+]+@[^"?]+\.+[^."?]+?)(\\\\?"|\?)/';
151151

152-
if (preg_match_all($pattern, $text, $matches)) {
153-
foreach ($matches[0] as $match) {
154-
$match = (string) str_replace(['?', '"'], '', $match);
155-
$text = (string) str_replace($match, PunycodeHelper::emailToPunycode($match), $text);
152+
if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) {
153+
foreach ($matches as $match) {
154+
$email = PunycodeHelper::emailToPunycode($match[2]);
155+
$text = str_replace($match[0], $match[1] . $email . $match[3], $text);
156156
}
157157
}
158158

0 commit comments

Comments
 (0)