Issue #3239472: preg_split in _filter_url breaks for long html tags
Merge request reports
Activity
- Resolved by Stefanos Petrakis
- Resolved by Stefanos Petrakis
added 1 commit
- e7737b16 - Using ternary operators, added test and revised comments.
added 1 commit
- 1948249c - Adding a URL to the simple HTML document to show that it is not modified.
523 523 // markup, especially a '>'. Therefore, remove all comment contents and add 524 524 // them back later. 525 525 _filter_url_escape_comments('', TRUE); 526 $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text); 526 // Default to the current text in case preg_replace_callback fails. 527 $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text) ?: $text; - Comment on lines +526 to +527
changed this line in version 6 of the diff
Ok, so this came up and produced an error (after I removed my fix earlier). I produced a newer version that tries to tackle the deprecation notice, based on the following:
So, the new code looks like this (8b3c882a)
- $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text); + $text = is_null($text) ? '' : preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text); // Split at all tags; ensures that no tags or attributes are processed. - $chunks = $text ? preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE) : FALSE; + $chunks = is_null($text) ? [''] : preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
Your thoughts @alexpott, @benji, @larowlan and anyone else that's got eyes on this one?
Edited by Stefanos Petrakis
added 1 commit
- c47b6647 - Avoid passing NULL text to preg_* functions.
added 6 commits
-
c47b6647...fb723608 - 5 commits from branch
project:10.1.x
- 1c803683 - Merge branch '10.1.x' into 3239472-reroll-101x
-
c47b6647...fb723608 - 5 commits from branch
- Resolved by Alex Pott
added 257 commits
-
1c803683...15744364 - 249 commits from branch
project:10.1.x
- e406a85d - Reroll against 10.1.x
- 0701b3f4 - Following review
- 86ec96a7 - Whitespace fix
- 74098255 - Using ternary operators, added test and revised comments.
- 2585b2d2 - Adding a URL to the simple HTML document to show that it is not modified.
- f5e951cc - Using the saved_text approach
- d8156cdc - Spellcheck fix
- 72cd2c12 - Avoid passing NULL text to preg_* functions.
Toggle commit list-
1c803683...15744364 - 249 commits from branch
added 1 commit
Please register or sign in to reply