diff --git a/.eslintrc b/.eslintrc index daf889cb05af8..048e910ad4f27 100644 --- a/.eslintrc +++ b/.eslintrc @@ -111,6 +111,7 @@ "no-useless-call": "error", "no-useless-catch": "error", "no-useless-concat": "error", + "no-useless-escape": "error", "no-useless-return": "error", "prefer-promise-reject-errors": "error", "wrap-iife": ["error", "any"], diff --git a/external/builder/builder.js b/external/builder/builder.js index edfb23cffa57b..997be77adeef7 100644 --- a/external/builder/builder.js +++ b/external/builder/builder.js @@ -202,7 +202,7 @@ function preprocessCSS(mode, source, destination) { } function expandImports(content, baseUrl) { - return content.replace(/^\s*@import\s+url\(([^\)]+)\);\s*$/gm, function ( + return content.replace(/^\s*@import\s+url\(([^)]+)\);\s*$/gm, function ( all, url ) { diff --git a/gulpfile.js b/gulpfile.js index 1c5d4c415e579..a39616c492a02 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -124,7 +124,7 @@ function safeSpawnSync(command, parameters, options) { options.shell = true; // `options.shell = true` requires parameters to be quoted. parameters = parameters.map(param => { - if (!/[\s`~!#$*(){\[|\\;'"<>?]/.test(param)) { + if (!/[\s`~!#$*(){[|\\;'"<>?]/.test(param)) { return param; } return '"' + param.replace(/([$\\"`])/g, "\\$1") + '"'; diff --git a/src/scripting_api/util.js b/src/scripting_api/util.js index 14f91e26aeb2f..dd3891ee4cf6b 100644 --- a/src/scripting_api/util.js +++ b/src/scripting_api/util.js @@ -61,7 +61,7 @@ class Util extends PDFObject { throw new TypeError("First argument of printf must be a string"); } - const pattern = /%(,[0-4])?([\+ 0#]+)?([0-9]+)?(\.[0-9]+)?(.)/g; + const pattern = /%(,[0-4])?([+ 0#]+)?([0-9]+)?(\.[0-9]+)?(.)/g; const PLUS = 1; const SPACE = 2; const ZERO = 4; diff --git a/src/shared/util.js b/src/shared/util.js index f29217b2a174c..f5416e18f099d 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -824,7 +824,7 @@ function escapeString(str) { // replace "(", ")", "\n", "\r" and "\" // by "\(", "\)", "\\n", "\\r" and "\\" // in order to write it in a PDF file. - return str.replace(/([\(\)\\\n\r])/g, match => { + return str.replace(/([()\\\n\r])/g, match => { if (match === "\n") { return "\\n"; } else if (match === "\r") { diff --git a/test/webserver.js b/test/webserver.js index 417dff25f73f4..cb89284d6b656 100644 --- a/test/webserver.js +++ b/test/webserver.js @@ -165,7 +165,7 @@ WebServer.prototype = { var range = req.headers.range; if (range && !disableRangeRequests) { - var rangesMatches = /^bytes=(\d+)\-(\d+)?/.exec(range); + var rangesMatches = /^bytes=(\d+)-(\d+)?/.exec(range); if (!rangesMatches) { res.writeHead(501); res.end("Bad range", "utf8"); diff --git a/web/app.js b/web/app.js index 731b9eab9a2ac..9f04d26c8d5e5 100644 --- a/web/app.js +++ b/web/app.js @@ -1552,7 +1552,7 @@ const PDFViewerApplication = { if (!producer.includes(generator)) { return false; } - generatorId = generator.replace(/[ .\-]/g, "_"); + generatorId = generator.replace(/[ .-]/g, "_"); return true; }); } diff --git a/web/debugger.js b/web/debugger.js index 26f4033032d6f..c79aeeecf9069 100644 --- a/web/debugger.js +++ b/web/debugger.js @@ -115,7 +115,7 @@ var FontInspector = (function FontInspectorClosure() { name.textContent = fontName; var download = document.createElement("a"); if (url) { - url = /url\(['"]?([^\)"']+)/.exec(url); + url = /url\(['"]?([^)"']+)/.exec(url); download.href = url[1]; } else if (fontObj.data) { download.href = URL.createObjectURL( diff --git a/web/ui_utils.js b/web/ui_utils.js index 32481fd0b5cc0..07c510a8f37a2 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -617,10 +617,10 @@ function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") { ); return defaultFilename; } - const reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/; - // SCHEME HOST 1.PATH 2.QUERY 3.REF + const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/; + // SCHEME HOST 1.PATH 2.QUERY 3.REF // Pattern to get last matching NAME.pdf - const reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i; + const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i; const splitURI = reURI.exec(url); let suggestedFilename = reFilename.exec(splitURI[1]) ||