Index: trunk/extensions/VisualEditor/tests/parser/parserTests-whitelist.js |
— | — | @@ -59,7 +59,14 @@ |
60 | 60 | // Sanitizer, but UTF8 in link might actually be ok in HTML5 |
61 | 61 | testWhiteList["External link containing double-single-quotes with no space separating the url from text in italics"] = "<p><a href=\"http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm\"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a data-type=\"internal\" href=\"Museo Picasso (París)\">Museo Picasso</a>.</p>"; |
62 | 62 | |
| 63 | +// plain percent sign is also valid in HTML5 |
| 64 | +testWhiteList["Bug 4781, 5267: %28, %29 in URL"] = "<p><a href=\"http://www.example.com/?title=Ben-Hur_(1959_film)\" data-sourcePos=\"0:53\">http://www.example.com/?title=Ben-Hur_(1959_film)</a></p>"; |
63 | 65 | |
| 66 | +testWhiteList["External links: wiki links within external link (Bug 3695)"] = "<p><a href=\"http://example.com\" data-type=\"external\" data-sourcePos=\"0:54\"></a><a data-type=\"internal\" href=\"wikilink\">wikilink</a> embedded in ext link</p>"; |
| 67 | + |
| 68 | +testWhiteList["Bug 4781, 5267: %25 in URL"] = "<p><a href=\"http://www.example.com/?title=100%_Bran\" data-sourcePos=\"0:41\">http://www.example.com/?title=100%_Bran</a></p>"; |
| 69 | + |
| 70 | + |
64 | 71 | if (typeof module == "object") { |
65 | 72 | module.exports.testWhiteList = testWhiteList; |
66 | 73 | } |
Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -199,7 +199,8 @@ |
200 | 200 | this.env = new MWParserEnvironment({ |
201 | 201 | fetchTemplates: false, |
202 | 202 | debug: this.argv.debug, |
203 | | - trace: this.argv.trace |
| 203 | + trace: this.argv.trace, |
| 204 | + wgScriptPath: '' |
204 | 205 | }); |
205 | 206 | } |
206 | 207 | |
— | — | @@ -313,7 +314,7 @@ |
314 | 315 | // general class and titles, typically on links |
315 | 316 | .replace(/(title|class|rel)="[^"]+"/g, '') |
316 | 317 | // strip red link markup, we do not check if a page exists yet |
317 | | - .replace(/\/index.php\?title=|&action=edit&redlink=1/g, '') |
| 318 | + .replace(/\/index.php\?title=([^']+)&action=edit&redlink=1/g, '$1') |
318 | 319 | // the expected html has some extra space in tags, strip it |
319 | 320 | .replace(/<a +href/g, '<a href') |
320 | 321 | .replace(/" +>/g, '">'); |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.ParserFunctions.js |
— | — | @@ -212,6 +212,18 @@ |
213 | 213 | return [ res.toString() ]; |
214 | 214 | }; |
215 | 215 | |
| 216 | +ParserFunctions.prototype['pf_localurl'] = function ( target, argList, argDict ) { |
| 217 | + return ( this.manager.env.wgScriptPath + '/index' + |
| 218 | + this.manager.env.wgScriptExtension + '?title=' + |
| 219 | + target + '&' + |
| 220 | + argList.map( |
| 221 | + function( kv ) { |
| 222 | + //console.log( JSON.stringify( kv ) ); |
| 223 | + return (kv.v !== '' && kv.k + '=' + kv.v ) || kv.k; |
| 224 | + } |
| 225 | + ).join('&') |
| 226 | + ); |
| 227 | +}; |
216 | 228 | |
217 | 229 | |
218 | 230 | /** |
Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -351,11 +351,11 @@ |
352 | 352 | } |
353 | 353 | |
354 | 354 | link_preprocessor_text |
355 | | - = r:( t:[^'<~[{\n\r|!\]}\t &=]+ { return t.join(''); } |
| 355 | + = r:( t:[^'<~[{\n\r|!\]}\t &="']+ { return t.join(''); } |
356 | 356 | / directive |
| 357 | + / urlencoded_char |
357 | 358 | / !inline_breaks no_punctuation_char |
358 | 359 | / s:[.:,] !(space / eolf) { return s } |
359 | | - / urlencoded_char |
360 | 360 | / [&%] )+ { |
361 | 361 | return flatten_string ( r ); |
362 | 362 | } |
— | — | @@ -687,7 +687,8 @@ |
688 | 688 | |
689 | 689 | |
690 | 690 | urllink |
691 | | - = target:url { |
| 691 | + = ! { return syntaxFlags['extlink'] } |
| 692 | + target:url { |
692 | 693 | return [ new TagTk( 'a', [new KV('href', target)] ) |
693 | 694 | , target |
694 | 695 | , new EndTagTk( 'a' ) |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.js |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | // Add token transformations.. |
79 | 79 | new QuoteTransformer( this.tokenPostProcessor ); |
80 | 80 | new PostExpandParagraphHandler( this.tokenPostProcessor ); |
81 | | - //new Sanitizer( this.tokenPostProcessor ); |
| 81 | + new Sanitizer( this.tokenPostProcessor ); |
82 | 82 | |
83 | 83 | //var citeExtension = new Cite( this.tokenTransformer ); |
84 | 84 | |