Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/232207

Change subject: T106945: Bare protocols are not autolinks
......................................................................

T106945: Bare protocols are not autolinks

Change-Id: I5d728e6ac388b6b2e71a0bda17164cb6de5cf96b
---
M lib/pegTokenizer.pegjs.txt
1 file changed, 8 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/07/232207/1

diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt
index 39a4120..4053f8b 100644
--- a/lib/pegTokenizer.pegjs.txt
+++ b/lib/pegTokenizer.pegjs.txt
@@ -524,6 +524,7 @@
 autourl
   = &{ return stops.push('autourl', { sawLParen: false }); }
     ! '//' // protocol-relative autolinks not allowed (T32269)
+    r:(
     proto:url_protocol
     addr:( ipv6_address / ipv4_address )?
     path:(  ( !{ return inlineBreaks(input, endOffset(), stops); } // 
inline_breaks
@@ -557,11 +558,15 @@
       strip = new RegExp('[' + Util.escapeRegExp(strip) + ']*$');
       trim = strip.exec(last)[0].length;
       url[url.length - 1] = last.slice(0, last.length - trim);
-      peg$currPos -= trim;
     }
+    url = tu.flattenString(url);
+    if (url.length <= proto.length) {
+      return null; // ensure we haven't stripped everything: T106945
+    }
+    peg$currPos -= trim;
     stops.pop('autourl');
-    return tu.flattenString(url);
-}
+    return url;
+} ) &{ return r !== null; } {return r; }
     / &{ return stops.pop('autourl'); }
 
 ipv4_address

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d728e6ac388b6b2e71a0bda17164cb6de5cf96b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

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

Reply via email to