ItSpiderman has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/367388 )

Change subject: VisualEditor: Fix for occasional editor hangs
......................................................................

VisualEditor: Fix for occasional editor hangs

When there is a special tag containing a template or switch inside, those
inner tags would get converted first causing extreme backtracking in regex
for special tags, because there would be a html element inside a special
tag that regex is trying to match.

Since templates and switches cannot contain another tag nested inside, now
special tags are rendered first to avoid this issue

ERM: #6826, 6743

Needs cherry-picking to REL1_27 and REL1_23

Change-Id: Ie457e2ead4c16f236f915d3d7649ce75e5e9ea21
---
M VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
1 file changed, 37 insertions(+), 37 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/88/367388/1

diff --git a/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js 
b/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
index 78c55a2..9eddb01 100644
--- a/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
+++ b/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
@@ -1706,6 +1706,43 @@
                        squareBraceFirst, tempTemplate, innerText,
                        templateName, templateNameLines;
 
+               //quirky. Needs to be there for the occasional second pass of 
cleanup
+               if (!_specialtags) {
+                       _specialtags = new Array();
+               }
+
+               specialTagsList = 
mw.config.get('BsVisualEditorConfigDefault').specialtaglist;
+               // Tags without innerHTML need /> as end marker. Maybe this 
should be task of a preprocessor, in order to allow mw style tags without /.
+               regex = '<(' + specialTagsList + 
')((\\s|\\r|\\n)+[^>]*)*?((\\s\\/>)|(\\/>)|(>([\\S\\s]*?((<\\/\\1>)|(<\\/ 
\\1>)))))';
+
+               matcher = new RegExp(regex, 'gmi');
+               mtext = text;
+               i = 0;
+               st = '';
+
+               var innerText = '';
+               var retValue = false;
+               var moreAttribs = '';
+
+               while ((st = matcher.exec(mtext)) !== null) {
+                       retValue = $(document).triggerHandler( 
'BSVisualEditorRenderSpecialTag', [this, st[1], st] );
+                       if ( retValue ) {
+                               innerText = retValue.innerText;
+                               moreAttribs = retValue.moreAttribs;
+                       } else {
+                               innerText = '&lt; ' + st[1] + ' &gt;';
+                       }
+                       text = text.replace(
+                               st[0],
+                               '<span class="mceNonEditable tag" 
id="bs_specialtag:@@@ST' + i + '@@@" data-bs-name="' + st[1] + '" 
data-bs-type="tag" data-bs-id="' + i + '" ' + moreAttribs + '>'
+                               //+ '&lt; ' + st[1] + ' &gt;'
+                               + innerText
+                               + '</span>'
+                               );
+                       _specialtags[i] = st[0];
+                       i++;
+               }
+
                if (!_switches) {
                        _switches = new Array();
                }
@@ -1803,43 +1840,6 @@
                                        + '</span>'
                                        );
                        }
-               }
-
-               //quirky. Needs to be there for the occasional second pass of 
cleanup
-               if (!_specialtags) {
-                       _specialtags = new Array();
-               }
-
-               specialTagsList = 
mw.config.get('BsVisualEditorConfigDefault').specialtaglist;
-               // Tags without innerHTML need /> as end marker. Maybe this 
should be task of a preprocessor, in order to allow mw style tags without /.
-               regex = '<(' + specialTagsList + 
')((\\s|\\r|\\n)+[^>]*)*?((\\s\\/>)|(\\/>)|(>([\\S\\s]*?((<\\/\\1>)|(<\\/ 
\\1>)))))';
-
-               matcher = new RegExp(regex, 'gmi');
-               mtext = text;
-               i = 0;
-               st = '';
-
-               var innerText = '';
-               var retValue = false;
-               var moreAttribs = '';
-
-               while ((st = matcher.exec(mtext)) !== null) {
-                       retValue = $(document).triggerHandler( 
'BSVisualEditorRenderSpecialTag', [this, st[1], st] );
-                       if ( retValue ) {
-                               innerText = retValue.innerText;
-                               moreAttribs = retValue.moreAttribs;
-                       } else {
-                               innerText = '&lt; ' + st[1] + ' &gt;';
-                       }
-                       text = text.replace(
-                               st[0],
-                               '<span class="mceNonEditable tag" 
id="bs_specialtag:@@@ST' + i + '@@@" data-bs-name="' + st[1] + '" 
data-bs-type="tag" data-bs-id="' + i + '" ' + moreAttribs + '>'
-                               //+ '&lt; ' + st[1] + ' &gt;'
-                               + innerText
-                               + '</span>'
-                               );
-                       _specialtags[i] = st[0];
-                       i++;
                }
 
                if (!_comments) {

-- 
To view, visit https://gerrit.wikimedia.org/r/367388
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie457e2ead4c16f236f915d3d7649ce75e5e9ea21
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: ItSpiderman <d.savulje...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to