jenkins-bot has submitted this change and it was merged.
Change subject: T106945: Bare protocols are not autolinks
......................................................................
T106945: Bare protocols are not autolinks
Change-Id: I5d728e6ac388b6b2e71a0bda17164cb6de5cf96b
---
M lib/pegTokenizer.pegjs.txt
M tests/parserTests-blacklist.js
2 files changed, 8 insertions(+), 5 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt
index 39a4120..d626d89 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.flattenStringlist(url);
+ if (url.length === 1 && url[0].constructor === String && url[0].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
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index d72545c..5802270 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -52,7 +52,6 @@
add("wt2html", "4. Indent-Pre and extension tags", "<pre
data-parsoid='{\"dsr\":[0,39,1,0]}'>a <span typeof=\"mw:Extension/gallery\"
about=\"#mwt1\"
data-parsoid='{\"stx\":\"html\",\"src\":\"<gallery>\\nFile:foobar.jpg\\n</gallery>\",\"tagWidths\":[9,10],\"autoInsertedEnd\":true,\"dsr\":[3,39,9,0]}'><gallery>\nFile:foobar.jpg\n</gallery></span></pre>");
add("wt2html", "6. Pre-blocks should extend across lines with leading WS even
when there is no wrappable content", "<pre
data-parsoid='{\"dsr\":[0,26,1,0]}'>a\n\n <!-- continue -->\nb</pre>\n\n<pre
data-parsoid='{\"dsr\":[28,30,1,0]}'>c</pre>\n \n<p
data-parsoid='{\"dsr\":[33,34,0,0]}'>d</p>");
add("wt2html", "Definition Lists: colons and tables 1", "<dl
data-parsoid='{\"dsr\":[0,21,0,0]}'><dd
data-parsoid='{\"dsr\":[0,10,1,0]}'><table
data-parsoid='{\"dsr\":[1,10,2,2]}'>\n<tbody
data-parsoid='{\"dsr\":[4,8,0,0]}'><tr
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[4,7,0,0]}'><td
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[4,7,1,0]}'>
x</td></tr>\n</tbody></table></dd>\n<dd
data-parsoid='{\"dsr\":[11,21,1,0]}'><table
data-parsoid='{\"dsr\":[12,21,2,2]}'>\n<tbody
data-parsoid='{\"dsr\":[15,19,0,0]}'><tr
data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[15,18,0,0]}'><td
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[15,18,1,0]}'>
y</td></tr>\n</tbody></table></dd></dl>");
-add("wt2html", "External links: Lone protocols are never linked (T105697)",
"<p data-parsoid='{\"dsr\":[0,56,0,0]}'>http://\n<a rel=\"mw:ExtLink\"
href=\"http://\"
data-parsoid='{\"stx\":\"url\",\"dsr\":[8,15,0,0]}'>http://</a>;\n(<a
rel=\"mw:ExtLink\" href=\"http://\"
data-parsoid='{\"stx\":\"url\",\"dsr\":[18,25,0,0]}'>http://</a>)\nbitcoin:\nbitcoin:;\n(bitcoin:)</p>");
add("wt2html", "Bug 2702: Mismatched <i>, <b> and <a> tags are invalid", "<p
data-parsoid='{\"dsr\":[0,204,0,0]}'><i
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[0,29,2,0]}'><a
rel=\"mw:ExtLink\" href=\"http://example.com\"
data-parsoid='{\"targetOff\":22,\"contentOffsets\":[22,28],\"dsr\":[2,29,20,1]}'>text<i
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[26,28,2,0]}'></i></a></i>\n<a
rel=\"mw:ExtLink\" href=\"http://example.com\"
data-parsoid='{\"targetOff\":50,\"contentOffsets\":[50,57],\"dsr\":[30,58,20,1]}'><b
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[50,57,3,0]}'>text</b></a><b
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[58,61,3,0]}'></b>\n<i
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[62,106,2,0]}'>Something <a
rel=\"mw:ExtLink\" href=\"http://example.com\"
data-parsoid='{\"targetOff\":94,\"contentOffsets\":[94,105],\"dsr\":[74,106,20,1]}'>in
italic<i
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[103,105,2,0]}'></i></a></i>\n<i
data-parsoid='{\"dsr\":[107,164,2,2]}'>Something <a rel=\"mw:ExtLink\"
href=\"http://example.com\"
data-parsoid='{\"targetOff\":139,\"contentOffsets\":[139,160],\"dsr\":[119,161,20,1]}'>mixed<b
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[144,160,3,0]}'><i
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[147,160,2,0]}'>, even
bold</i></b></a>'</i>\n<b
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[165,204,3,0]}'><i
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[168,204,2,0]}'>Now <a
rel=\"mw:ExtLink\" href=\"http://example.com\"
data-parsoid='{\"targetOff\":194,\"contentOffsets\":[194,203],\"dsr\":[174,204,20,1]}'>both<b
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[198,203,3,0]}'><i
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[201,203,2,0]}'></i></b></a></i></b></p>");
add("wt2html", "External link containing double-single-quotes in text embedded
in italics (bug 4598 sanity check)", "<p data-parsoid='{\"dsr\":[0,60,0,0]}'><i
data-parsoid='{\"dsr\":[0,60,2,2]}'>Some <a rel=\"mw:ExtLink\"
href=\"http://example.com/\"
data-parsoid='{\"targetOff\":28,\"contentOffsets\":[28,56],\"dsr\":[7,57,21,1]}'>pretty
<i data-parsoid='{\"dsr\":[35,46,2,2]}'>italics</i> and stuff</a>!</i></p>");
add("wt2html", "Self-link to numeric title", "<p
data-parsoid='{\"dsr\":[0,5,0,0]}'><a rel=\"mw:WikiLink\" href=\"./0\"
title=\"0\"
data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./0\"},\"sa\":{\"href\":\"0\"},\"dsr\":[0,5,2,2]}'>0</a></p>");
@@ -806,7 +805,6 @@
add("html2wt", "Definition Lists: colons and tables 1", ": {|\n\n| x\n|}\n\n:
{|\n\n| y\n|}\n");
add("html2wt", "Definition Lists: colons and tables 2", ": {|\n\n| x\n|}\n:
{|\n\n| y\n|}\n");
add("html2wt", "External links: Free with trailing punctuation",
"http://example.com,\nhttp://example.com;\nhttp://example.com\\\nhttp://example.com.\nhttp://example.com:\nhttp://example.com!\nhttp://example.com?\nhttp://example.com)\nhttp://example.com/url_with_(brackets)\n(http://example.com/url_without_brackets)\nhttp://example.com/url_with_entity \nhttp://example.com/url_with_entity \nhttp://example.com/url_with_entity \nhttp://example.com/url_with_entity<nowiki/><\nhttp://example.com/url_with_entity<\nhttp://example.com/url_with_entity<\n");
-add("html2wt", "External links: Lone protocols are never linked (T105697)",
"<nowiki>http://\nhttp://;\n(http://)\nbitcoin:\nbitcoin:;\n(bitcoin:)</nowiki>\n");
add("html2wt", "External links: URL in text", "URL in text:
http://example.com\n");
add("html2wt", "External links: raw ampersand", "Old & use: http://x&y\n");
add("html2wt", "External links: encoded ampersand", "Old & use:
http://x&y\n");
--
To view, visit https://gerrit.wikimedia.org/r/232207
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5d728e6ac388b6b2e71a0bda17164cb6de5cf96b
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: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits