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

Side by Side Diff: chrome/content/ui/sendReport.js

Issue 29333409: Issue 3505 - Fixed: Issue reporter calls String.replace() with deprecated flags parameter (Closed)
Patch Set: Created Jan. 12, 2016, 5:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 let [pathID, placeholder] = pathList[i]; 610 let [pathID, placeholder] = pathList[i];
611 try 611 try
612 { 612 {
613 let file = FileUtils.getDir(pathID, [], false); 613 let file = FileUtils.getDir(pathID, [], false);
614 censored[file.path.replace(/[\\\/]+$/, '')] = placeholder; 614 censored[file.path.replace(/[\\\/]+$/, '')] = placeholder;
615 let uri = Utils.ioService.newFileURI(file); 615 let uri = Utils.ioService.newFileURI(file);
616 censored[uri.spec.replace(/[\\\/]+$/, '')] = placeholder; 616 censored[uri.spec.replace(/[\\\/]+$/, '')] = placeholder;
617 } catch(e) {} 617 } catch(e) {}
618 } 618 }
619 619
620 function str2regexp(str, flags)
621 {
622 return new RegExp(str.replace(/(\W)/g, "\\$1"), flags);
Thomas Greiner 2016/01/12 17:53:39 You can avoid the creation of the capturing group
Wladimir Palant 2016/01/12 17:59:12 Done.
623 }
624
620 let errors = reportElement("errors"); 625 let errors = reportElement("errors");
621 for (let i = 0; i < messages.length; i++) 626 for (let i = 0; i < messages.length; i++)
622 { 627 {
623 let message = messages[i]; 628 let message = messages[i];
624 629
625 let text = message.errorMessage; 630 let text = message.errorMessage;
626 for (let path in censored) 631 for (let path in censored)
627 text = text.replace(path, censored[path], "gi"); 632 text = text.replace(str2regexp(path, "gi"), censored[path]);
628 if (text.length > 256) 633 if (text.length > 256)
629 text = text.substr(0, 256) + "..."; 634 text = text.substr(0, 256) + "...";
630 635
631 let file = message.sourceName; 636 let file = message.sourceName;
632 for (let path in censored) 637 for (let path in censored)
633 file = file.replace(path, censored[path], "gi"); 638 file = file.replace(str2regexp(path, "gi"), censored[path]);
634 if (file.length > 256) 639 if (file.length > 256)
635 file = file.substr(0, 256) + "..."; 640 file = file.substr(0, 256) + "...";
636 641
637 let sourceLine = message.sourceLine; 642 let sourceLine = message.sourceLine;
638 if (sourceLine.length > 256) 643 if (sourceLine.length > 256)
639 sourceLine = sourceLine.substr(0, 256) + "..."; 644 sourceLine = sourceLine.substr(0, 256) + "...";
640 645
641 appendElement(errors, "error", { 646 appendElement(errors, "error", {
642 type: message.flags & Ci.nsIScriptError.warningFlag ? "warning" : "error ", 647 type: message.flags & Ci.nsIScriptError.warningFlag ? "warning" : "error ",
643 text: text, 648 text: text,
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 1554
1550 function censorURL(url) 1555 function censorURL(url)
1551 { 1556 {
1552 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); 1557 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*");
1553 } 1558 }
1554 1559
1555 function encodeHTML(str) 1560 function encodeHTML(str)
1556 { 1561 {
1557 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;"); 1562 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;");
1558 } 1563 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld