1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

Fix appFlexCopy improperly trimming newlines and spaces (#31)

This commit is contained in:
Philipp Rudloff 2019-03-21 14:51:37 +01:00 committed by Kyle Spearrin
parent 50e6f24679
commit cefab5f47f

View File

@ -21,7 +21,13 @@ export class FlexCopyDirective {
for (let i = 0; i < selection.rangeCount; i++) {
const range = selection.getRangeAt(i);
const text = range.toString();
copyText += text;
// The selection should only contain one line of text. In some cases however, the
// selection contains newlines and space characters from the identation of following
// sibling nodes. To avoid copying passwords containing trailing newlines and spaces
// that arent part of the password, the selection has to be trimmed.
const stringEndPos = text.includes('\n') ? text.search(/\r?\n/) : text.length;
copyText += text.substring(0, stringEndPos);
}
this.platformUtilsService.copyToClipboard(copyText, { window: window });
}