Left: | ||
Right: |
OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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, "&").replace(/</g, "<").replace(/>/g, ">"). replace(/"/g, """); | 1562 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"). replace(/"/g, """); |
1558 } | 1563 } |
OLD | NEW |