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

Change subject: Support bitcoin:, redis:, urn:, xmpp:, etc protocols (part 2).
......................................................................


Support bitcoin:, redis:, urn:, xmpp:, etc protocols (part 2).

Our production for urltext was eating up characters which should
be included in the start of the autolink production.  Rather than
add additional character piecemeal to correspond to various possible
protocols, just disallow [A-Za-z] in the initial urltext shortcut.

Fix up url_protocol to allow `//` as a protocol-relative prefix
without eating up word characters afterward.  But explicitly
disallow protocol-relative URLs in the autolink production, matching
the behavior of the PHP parser (added in
https://phabricator.wikimedia.org/rSVN94502 to fix T32269).

Follow up to I84bed603cc7945b1e2d5680a507ae0f8ebd6f994.

Change-Id: I8cc61f4cb6b3fdee834fcff7e8f4589617d6b39c
---
M lib/pegTokenizer.pegjs.txt
1 file changed, 4 insertions(+), 35 deletions(-)

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



diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt
index 3259c88..2540b7e 100644
--- a/lib/pegTokenizer.pegjs.txt
+++ b/lib/pegTokenizer.pegjs.txt
@@ -482,16 +482,7 @@
 
 url_protocol =
     & { return Util.isProtocolValid(input.substr(endOffset()), options.env); }
-    h:$[a-zA-Z\/]+ c:':'? s:'//'?
-{
-    if (c) {
-        h += c;
-    }
-    if (s) {
-        h += s;
-    }
-    return h;
-}
+    p:$( '//' / [A-Za-z] [-A-Za-z0-9+.]* ':' '//'? ) { return p; }
 
 // no punctuation, and '{<' to trigger directives
 no_punctuation_char = [^ 
:\]\[\r\n"'<>\x00-\x20\x7f,.&%\u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000{]
@@ -531,6 +522,7 @@
 // which aren't included in no_punctuation_char
 autourl
   = &{ return stops.push('autourl', { sawLParen: false }); }
+    ! '//' // protocol-relative autolinks not allowed (T32269)
     proto:url_protocol
     addr:( ipv6_address / ipv4_address )?
     path:(  ( !{ return inlineBreaks(input, endOffset(), stops); } // 
inline_breaks
@@ -1774,12 +1766,7 @@
  * {    start of parser functions, transclusion and template args
  * \n   all sort of block-level markup at start of line
  * \r   ditto
- * h    http(s) urls
- * n    nntp(s) urls
- * m    mailto urls
- * I    start of ISBN 10/13 auto links
- * P    start of PMID auto links
- * R    start of RFC auto links
+ * A-Za-z autolinks (http(s), nttp(s), mailto, ISBN, PMID, RFC)
  *
  * _    behavior switches (e.g., '__NOTOC__') (XXX: not URL related)
  * ! and | table cell delimiters, might be better to specialize those
@@ -1794,7 +1781,7 @@
  * ;    separator in lang_variant
  */
 
-urltext = ( $[^-'<~[{\n\pPrRfFgGhHiImMnNsStTwW_|!:;\]} &=]+
+urltext = ( $[^-'<~[{\n/A-Za-z_|!:;\]} &=]+
           / & [/A-Za-z] al:autolink { return al; }
           / & "&" he:htmlentity { return he; }
           // Convert trailing space into &nbsp;
@@ -1811,24 +1798,6 @@
           // About 96% of text_char calls originate here.
           // pegjs 0.8 inlines this simple rule automatically.
           / text_char )+
-
-/*
-    '//', // for protocol-relative URLs, but not in text!
-    'ftp://',
-    'git://',
-    'gopher://',
-    'http://',
-    'https://',
-    'irc://',
-    'ircs://',  // @bug 28503
-    'mailto:',
-    'mms://',
-    'news:',
-    'nntp://', // @bug 3808 RFC 1738
-    'svn://',
-    'telnet://', // Well if we're going to support the above.. -ævar
-    'worldwind://',
-*/
 
 htmlentity = m:$("&" [#0-9a-zA-Z]+ ";") {
     var cc = Util.decodeEntities(m);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8cc61f4cb6b3fdee834fcff7e8f4589617d6b39c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to