Skip to content

Commit

Permalink
Fixed phishing warning when pasting bookmark
Browse files Browse the repository at this point in the history
I wasn't filling in the blanks.
  • Loading branch information
alanhkarp committed Oct 23, 2023
1 parent 5aa204d commit 9cb2cbb
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/ssp.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,25 +399,26 @@ let SitePasswordWeb = ((function (self) {
// bookmark = ssp://{"domainname":"alantheguru.alanhkarp.com","sitename":"The Real Alan","username":"dalnefre","pwlength":"15","startwithletter":false,"allowlower":true,"minlower":"1","allowupper":true,"minupper":"1","allownumber":true,"minnumber":"1","allowspecial":true,"minspecial":"1","specials":"$/!=@?._-"}
// sitepw --> G.iJQEp-qB65UF5
$bookmark.onpaste = function () {
// The paste result isn't available until the next turn
setTimeout(() => {
self.bookmarkPaste();
}, 0);
}
self.bookmarkPaste = function () {
const settings = parseBookmark($bookmark.value);
$bookmark.value = ""; // clear bookmark field
if (settings) {
if (settings.domainname === $domainname.value) {
SitePassword.settings = settings; // update data-model
updateSettings(settings);
} else {
$sitename.value = settings.sitename;
//alert("Bookmark is not for this domain. Try another one.");
phishingWarningOn(settings);
}
$bookmark.value = ""; // clear bookmark field
if (settings) {
if (settings.domainname === $domainname.value) {
SitePassword.settings = settings; // update data-model
updateSettings(settings);
} else {
alert("Invalid bookmark. Copy it again?");
$sitename.value = settings.sitename;
//alert("Bookmark is not for this domain. Try another one.");
phishingWarningOn(settings);
}
} else {
alert("Invalid bookmark. Copy it again?");
}
}
const $httpclose = get("httpclose");
$httpclose.onclick = function () {
Expand Down Expand Up @@ -706,6 +707,10 @@ let SitePasswordWeb = ((function (self) {
}
function phishingWarningOn(settings) {
httpWarningOff();
const domainname = $domainname.value;
const sitename = settings.sitename;
let testDomain = SitePassword.validateDomain(domainname, sitename);
phishingWarningMsg(testDomain);
$phishing.style.display = "block";
$results.style.display = "none"; // hide sitepw/remember/settings...
$domainname.classList.add("bad-input");
Expand Down Expand Up @@ -737,7 +742,7 @@ let SitePasswordWeb = ((function (self) {
}
function phishingWarningMsg(testDomain) {
let sitename = normalize($sitename.value);
get("phishingtext0").innerText = get("sitename").value;
get("phishingtext0").innerText = sitename;
get("phishingtext1").innerText = testDomain;
get("phishingtext2").innerText = get("domainname").value;
}
Expand Down

0 comments on commit 9cb2cbb

Please sign in to comment.