From 0d1dbdd0a7ec840ebde8499f52f736efde244553 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Thu, 13 May 2021 02:18:54 +0800 Subject: [PATCH] related to #75 mask password input by default --- src/snapshot.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/snapshot.ts b/src/snapshot.ts index 29b1f16c..532fe16a 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -110,7 +110,7 @@ export function absoluteToStylesheet( ); } -const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/; // Don't use \s, to avoid matching non-breaking space +const SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/; // Don't use \s, to avoid matching non-breaking space const SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/; function getAbsoluteSrcsetString(doc: Document, attributeValue: string) { /* @@ -129,7 +129,7 @@ function getAbsoluteSrcsetString(doc: Document, attributeValue: string) { function collectCharacters(regEx: RegExp) { var chars, - match = regEx.exec(attributeValue.substring(pos)); + match = regEx.exec(attributeValue.substring(pos)); if (match) { chars = match[0]; pos += chars.length; @@ -148,13 +148,13 @@ function getAbsoluteSrcsetString(doc: Document, attributeValue: string) { let url = collectCharacters(SRCSET_NOT_SPACES); if (url.slice(-1) === ',') { // aside: according to spec more than one comma at the end is a parse error, but we ignore that - url = absoluteToDoc(doc, url.substring(0, url.length - 1)) + url = absoluteToDoc(doc, url.substring(0, url.length - 1)); // the trailing comma splits the srcset, so the interpretion is that // another url will follow, and the descriptor is empty output.push(url); } else { let descriptorsStr = ''; - url = absoluteToDoc(doc, url) + url = absoluteToDoc(doc, url); let inParens = false; while (true) { let c = attributeValue.charAt(pos); @@ -165,7 +165,7 @@ function getAbsoluteSrcsetString(doc: Document, attributeValue: string) { if (c === ',') { pos += 1; output.push((url + descriptorsStr).trim()); - break; // parse the next url + break; // parse the next url } else if (c === '(') { inParens = true; } @@ -863,9 +863,12 @@ function snapshot( week: true, textarea: true, select: true, + password: true, } : maskAllInputs === false - ? {} + ? { + password: true, + } : maskAllInputs; const slimDOMOptions: SlimDOMOptions = slimDOM === true || slimDOM === 'all'