Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ DIST := ../dist
OUT := $(DIST)/webcat-extension.zip
OUT_TEST := $(DIST)/webcat-extension-test.zip

INPUTS := manifest.json dist/bundle.js dist/hooks/content.js icons pages data
INPUTS := manifest.json dist/bundle.js dist/hooks/content.js icons pages data _locales
FIXED_MTIME := 198001010000

all: package package-test
Expand Down
23 changes: 23 additions & 0 deletions extension/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"advanced": {
"message": "Advanced"
},
"hideAdvanced": {
"message": "Hide advanced"
},
"thisSite": {
"message": "this site"
},
"webcatVerificationSuccessful": {
"message": "WEBCAT verification successful"
},
"webcatVerificationFailed": {
"message": "WEBCAT verification failed"
},
"webcatIsRunning": {
"message": "WEBCAT is running"
},
"webcatIsUnavailable": {
"message": "WEBCAT unavailable on this site."
}
}
47 changes: 47 additions & 0 deletions extension/_locales/fi/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"warningSecurityRisk": {
"message": "Varoitus: Tietoturvariski"
},
"didNotVerify": {
"message": "Ei varmennettu"
},
"errorShortDesc": {
"message": "WEBCAT ei voinut varmentaa, että koodi, jonka $1 tarjoili, vastaa allekirjoitettua manifestia, joten sivu estettiin."
},
"thisSite": {
"message": "tämä sivusto"
},
"advanced": {
"message": "Lisätietoja"
},
"hideAdvanced": {
"message": "Piilota lisätiedot"
},
"goBack": {
"message": "Palaa takaisin"
},
"whatYouCanDo": {
"message": "Ongelma johtuu sivustosta, ei verkkoyhteydestäsi. Koodi tai ympäristö, jonka sivusto tarjoili, ei vastaa sen kehittäjien kryptografista allekirjoitusta, joten WEBCAT esti sivun pitääkseen sinut turvassa. Voit ilmoittaa ongelmasta sivuston omistajalle, tai jos luulet tämän olevan bugi, raportoida sen $1."
},
"webcatRepository": {
"message": "WEBCATin tietovarastoon"
},
"file": {
"message": "Tiedosto: $1"
},
"errorCode": {
"message": "Virhekoodi: $1"
},
"webcatVerificationSuccessful": {
"message": "WEBCAT-varmennus onnistui"
},
"webcatVerificationFailed": {
"message": "WEBCAT-varmennus epäonnistui"
},
"webcatIsRunning": {
"message": "WEBCAT on käynnissä"
},
"webcatIsUnavailable": {
"message": "WEBCAT ei käytettävissä tällä sivustolla."
}
}
5 changes: 3 additions & 2 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"48": "icons/light/webcat.SVG",
"128": "icons/light/webcat.SVG"
},
"default_title": "WEBCAT unavailable on this site."
}
"default_title": "__MSG_webcatIsUnavailable__"
},
"default_locale": "en"
}
39 changes: 28 additions & 11 deletions extension/pages/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,58 @@
<link rel="stylesheet" href="chrome://global/skin/aboutNetError.css" />
<link rel="stylesheet" href="error.css" />
<script src="error.js"></script>
<title>Warning: Security Risk</title>
<title data-i18n="warningSecurityRisk">Warning: Security Risk</title>
</head>
<body class="certerror webcaterror">
<div class="container">
<div id="text-container">
<div class="title">
<h1 class="title-text">Did not verify</h1>
<h1 class="title-text" data-i18n="didNotVerify">Did not verify</h1>
</div>

<p id="errorShortDesc">
<p id="errorShortDesc" data-i18n="errorShortDesc">
WEBCAT could not verify that the code served by
<span id="error-host">this site</span> matches its signed manifest, so
the page was blocked.
<span id="error-host" data-i18n="thisSite">this site</span> matches
its signed manifest, so the page was blocked.
</p>

<div class="button-container">
<button id="advancedButton" aria-expanded="false">Advanced</button>
<button id="returnButton" class="primary">Go back</button>
<button
id="advancedButton"
aria-expanded="false"
data-i18n="advanced"
>
Advanced
</button>
<button id="returnButton" class="primary" data-i18n="goBack">
Go back
</button>
</div>

<div id="errorDebugInformation" hidden="">
<p id="whatCanYouDo">
<p id="whatCanYouDo" data-i18n="whatYouCanDo">
The problem is with the site, not your connection. The code or the
environment it served do not match what its developers
cryptographically signed, so WEBCAT blocked the page to keep you
safe. You can let the site owner know, or if you believe this is a
bug open an issue in the
<a href="https://github.com/freedomofpress/webcat"
<a
href="https://github.com/freedomofpress/webcat"
data-i18n="webcatRepository"
>WEBCAT repository</a
>.
</p>
<p class="error-detail" id="debug-file-line" hidden="">
<p
class="error-detail"
id="debug-file-line"
hidden=""
data-i18n="file"
>
File: <span id="debug-file"></span>
</p>
<p id="errorCode">Error code: <span id="debug-code"></span></p>
<p id="errorCode" data-i18n="errorCode">
Error code: <span id="debug-code"></span>
</p>
</div>
</div>
</div>
Expand Down
24 changes: 21 additions & 3 deletions extension/pages/error.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
document.addEventListener("DOMContentLoaded", () => {
function localize(container) {
container.querySelectorAll("[data-i18n]").forEach((el) => {
const substitutions = Array.from(el.children).map(
(child) => child.outerHTML,
);
const msg = browser.i18n.getMessage(
el.getAttribute("data-i18n"),
substitutions,
);
if (msg === "") {
return;
}
el.innerHTML = msg;
localize(el);
});
}
localize(document);

const params = new URLSearchParams(location.hash.slice(1));
const code = params.get("code") || "UNKNOWN";
const host = params.get("host") || "";
const file = params.get("file") || "";

setText("error-host", host || "this site");
setText("error-host", host || browser.i18n.getMessage("thisSite"));
setText("debug-code", code);

if (file) {
Expand All @@ -18,8 +36,8 @@ document.addEventListener("DOMContentLoaded", () => {
advancedPanel.hidden = !advancedPanel.hidden;
advancedButton.setAttribute("aria-expanded", String(!advancedPanel.hidden));
advancedButton.textContent = advancedPanel.hidden
? "Advanced"
: "Hide advanced";
? browser.i18n.getMessage("advanced")
: browser.i18n.getMessage("hideAdvanced");
});

// The error page took a history slot
Expand Down
9 changes: 6 additions & 3 deletions extension/src/webcat/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export function setIcon(tabId: number) {
tabId: tabId,
path: `icons/${theme}/webcat.SVG`,
});
browser.pageAction.setTitle({ tabId, title: "WEBCAT is running" });
browser.pageAction.setTitle({
tabId,
title: browser.i18n.getMessage("webcatIsRunning"),
});
}

export function setOKIcon(tabId: number, delegation?: string) {
Expand All @@ -43,7 +46,7 @@ export function setOKIcon(tabId: number, delegation?: string) {
path: `icons/${theme}/webcat-ok.SVG`,
});

let message = "WEBCAT verification successful";
let message = browser.i18n.getMessage("webcatVerificationSuccessful");
if (delegation) {
message += ` (${delegation})`;
}
Expand All @@ -69,7 +72,7 @@ export function setErrorIcon(tabId: number) {
});
browser.pageAction.setTitle({
tabId: tabId,
title: "WEBCAT verification failed",
title: browser.i18n.getMessage("webcatVerificationFailed"),
});
}

Expand Down
Loading