Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: include.postload.js

Issue 4567408790470656: Issue 1393 - Block element dialog suggests decoded URLs (Closed)
Left Patch Set: Created Sept. 18, 2014, 3:10 p.m.
Right Patch Set: Created Sept. 22, 2014, 1:13 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 var elt = currentElement; 272 var elt = currentElement;
273 var url = null; 273 var url = null;
274 if (currentElement.className && currentElement.className == "__adblockplus__ov erlay") 274 if (currentElement.className && currentElement.className == "__adblockplus__ov erlay")
275 { 275 {
276 elt = currentElement.prisoner; 276 elt = currentElement.prisoner;
277 url = currentElement.prisonerURL; 277 url = currentElement.prisonerURL;
278 } 278 }
279 else if (elt.src) 279 else if (elt.src)
280 url = elt.src; 280 url = elt.src;
281 281
282 // Only normalize when the element contains a URL (issue 328.)
283 // The URL is not always normalized, so do it here
284 if (url)
285 url = normalizeURL(relativeToAbsoluteUrl(url));
286
287 // Construct filters. The popup will retrieve these. 282 // Construct filters. The popup will retrieve these.
288 // Only one ID 283 // Only one ID
289 var elementId = elt.id ? elt.id.split(' ').join('') : null; 284 var elementId = elt.id ? elt.id.split(' ').join('') : null;
290 // Can have multiple classes, and there might be extraneous whitespace 285 // Can have multiple classes, and there might be extraneous whitespace
291 var elementClasses = null; 286 var elementClasses = null;
292 if (elt.className) 287 if (elt.className)
293 elementClasses = elt.className.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '' ).split(' '); 288 elementClasses = elt.className.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '' ).split(' ');
294 289
295 clickHideFilters = new Array(); 290 clickHideFilters = new Array();
296 selectorList = new Array(); 291 selectorList = new Array();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // No data attribute, look in PARAM child tags for a URL for the swf file 337 // No data attribute, look in PARAM child tags for a URL for the swf file
343 var params = elt.querySelectorAll("param[name=\"movie\"]"); 338 var params = elt.querySelectorAll("param[name=\"movie\"]");
344 // This OBJECT could contain an EMBED we already nuked, in which case there' s no URL 339 // This OBJECT could contain an EMBED we already nuked, in which case there' s no URL
345 if(params[0]) 340 if(params[0])
346 url = params[0].getAttribute("value"); 341 url = params[0].getAttribute("value");
347 else { 342 else {
348 params = elt.querySelectorAll("param[name=\"src\"]"); 343 params = elt.querySelectorAll("param[name=\"src\"]");
349 if(params[0]) 344 if(params[0])
350 url = params[0].getAttribute("value"); 345 url = params[0].getAttribute("value");
351 } 346 }
347
348 if (url)
349 url = normalizeURL(relativeToAbsoluteUrl(url));
Sebastian Noack 2014/09/22 13:27:49 I just realized that Chrome preserves slashes in U
Sebastian Noack 2014/09/22 13:37:36 Also unencoded special characters aren't encoded b
Thomas Greiner 2014/09/22 15:08:28 The question is whether we need to have a well-for
Sebastian Noack 2014/09/22 15:25:16 I don't say that the we should strip repeated slas
Sebastian Noack 2014/09/22 15:50:59 Actually using an <iframe> element is notable fast
Wladimir Palant 2014/09/22 17:39:21 That should be because Chrome does some caching of
Sebastian Noack 2014/09/23 09:40:34 Very interesting. So I agree with your point for u
Sebastian Noack 2014/09/25 07:53:18 LGTM. I created a separate issue, for using an <a>
352 } else if(!url) { 350 } else if(!url) {
353 url = elt.getAttribute("src") || elt.getAttribute("href"); 351 url = elt.src || elt.href;
354 } 352 }
355 return url; 353 return url;
356 } 354 }
357 355
358 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js 356 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js
359 // and licensed under the MIT license. See jquery-*.min.js for details. 357 // and licensed under the MIT license. See jquery-*.min.js for details.
360 function removeDotSegments(u) { 358 function removeDotSegments(u) {
361 var r = '', m = []; 359 var r = '', m = [];
362 if (/\./.test(u)) { 360 if (/\./.test(u)) {
363 while (u !== undefined && u !== '') { 361 while (u !== undefined && u !== '') {
(...skipping 16 matching lines...) Expand all
380 } 378 }
381 return r; 379 return r;
382 } else { 380 } else {
383 return u; 381 return u;
384 } 382 }
385 } 383 }
386 384
387 // Does some degree of URL normalization 385 // Does some degree of URL normalization
388 function normalizeURL(url) 386 function normalizeURL(url)
389 { 387 {
390 url = encodeURI(url);
Wladimir Palant 2014/09/18 18:53:02 What if the URL we get is already encoded? This fu
Sebastian Noack 2014/09/19 10:13:32 Thomas, can you please explain / figure out why th
Thomas Greiner 2014/09/19 10:47:13 Now I see what you mean. Element.src does give us
Sebastian Noack 2014/09/19 11:14:50 Yes, .src always returns a quoted URL no matter ho
Wladimir Palant 2014/09/21 18:37:42 The other advantage here is that element.src retur
Thomas Greiner 2014/09/22 09:37:33 I didn't find any reason against applying it to ob
391 var components = url.match(/(.+:\/\/.+?)\/(.*)/); 388 var components = url.match(/(.+:\/\/.+?)\/(.*)/);
392 if(!components) 389 if(!components)
393 return url; 390 return url;
394 var newPath = removeDotSegments(components[2]); 391 var newPath = removeDotSegments(components[2]);
395 if(newPath.length == 0) 392 if(newPath.length == 0)
396 return components[1]; 393 return components[1];
397 if(newPath[0] != '/') 394 if(newPath[0] != '/')
398 newPath = '/' + newPath; 395 newPath = '/' + newPath;
399 return components[1] + newPath; 396 return components[1] + newPath;
400 } 397 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 557
561 clickHide_deactivate(); 558 clickHide_deactivate();
562 } 559 }
563 break; 560 break;
564 default: 561 default:
565 sendResponse({}); 562 sendResponse({});
566 break; 563 break;
567 } 564 }
568 }); 565 });
569 } 566 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld