Cscott has uploaded a new change for review. https://gerrit.wikimedia.org/r/230834
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, 3 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/34/230834/1 diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt index 3259c88..c0baabe 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]+ ':'? '//'? ) { 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 @@ -1794,7 +1786,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 -- To view, visit https://gerrit.wikimedia.org/r/230834 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8cc61f4cb6b3fdee834fcff7e8f4589617d6b39c 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
