Incorrect detection of HTML tags
authorAlexander Ebert <ebert@woltlab.com>
Mon, 27 Sep 2021 15:00:48 +0000 (17:00 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 27 Sep 2021 15:00:48 +0000 (17:00 +0200)
The previous regex was incorrect and caused false-positive matches. One such case was a `<td>The …</td>` which translated into `###td ###The …`, causing it to be recognized as a `<th>`.

The new regex is much more restrictive by requiring at least one whitespace after the tag name if there is additional content.

wcfsetup/install/files/js/3rdParty/redactor2/redactor.js

index 0a6091a78568101653fa1e920a4ecf379bc3f96d..e8fff4caf84e0fbf7b1e638b3a42cfbdd44b332f 100644 (file)
                                        for (var i = 0; i < len; i++) {
                                                if (tags[i] === 'td' || tags[i] === 'th') {
                                                        html = html.replace(
-                                                               new RegExp('###' + tags[i] + '\s?(.*?[^#])###', 'gi'),
+                                                               new RegExp('###' + tags[i] + '(?:\\s?|\\s([^#]*?))###', 'gi'),
                                                                '<' + tags[i] + '$1>'
                                                        );
                                                }