jenkins-bot has submitted this change and it was merged.

Change subject: UnicodeJS treating start/end tags as letters
......................................................................


UnicodeJS treating start/end tags as letters

Because /[a-z]/.test(null) treats null as the string 'null' and
so returns true.

Bug: 48487
Change-Id: I2408229cddd876ff8fe55a9eddf9bac87a61457e
---
M modules/unicodejs/unicodejs.wordbreak.js
M modules/unicodejs/unicodejs.wordbreak.test.js
2 files changed, 8 insertions(+), 2 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/unicodejs/unicodejs.wordbreak.js 
b/modules/unicodejs/unicodejs.wordbreak.js
index f6a9e3c..910038d 100644
--- a/modules/unicodejs/unicodejs.wordbreak.js
+++ b/modules/unicodejs/unicodejs.wordbreak.js
@@ -23,6 +23,12 @@
        }
 
        function getGroup( chr ) {
+               // chr is always converted to a string by RegExp#test
+               // e.g. null -> 'null' and would match /[a-z]/
+               // so return null for any non-string value
+               if ( typeof chr !== 'string' ) {
+                       return null;
+               }
                var group;
                for ( group in patterns ) {
                        if ( patterns[group].test( chr ) ) {
diff --git a/modules/unicodejs/unicodejs.wordbreak.test.js 
b/modules/unicodejs/unicodejs.wordbreak.test.js
index 769e610..ca33b26 100644
--- a/modules/unicodejs/unicodejs.wordbreak.test.js
+++ b/modules/unicodejs/unicodejs.wordbreak.test.js
@@ -22,7 +22,7 @@
                        // 40 - 50
                        "汉字/漢字 c\u0300\u0327k" +
                        // 50 - 60
-                       " c\u0300\u0327",
+                       " c\u0300\u0327 a.",
                        /*jshint quotmark:single */
                textString = new unicodeJS.TextString( text ),
                breaks = [
@@ -31,7 +31,7 @@
                        21, 25, 30,
                        31, 39, 40,
                        41, 42, 43, 44, 45, 46, 50,
-                       51, 54
+                       51, 54, 55, 56, 57
                ];
 
        QUnit.expect( text.length + 1 );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2408229cddd876ff8fe55a9eddf9bac87a61457e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to