Bug 1659293 - fix cert viewer for certificates without a common name, r=prathiksha,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D94215
This commit is contained in:
Gijs Kruitbosch 2020-10-21 22:09:07 +00:00
Родитель d84e779913
Коммит cdd84eee88
6 изменённых файлов: 84 добавлений и 9 удалений

Просмотреть файл

@ -77,7 +77,11 @@ const getElementByPathOrFalse = (obj, pathString) => {
export const adjustCertInformation = cert => {
let certItems = [];
let tabName = cert.subject ? cert.subject.cn || "" : "";
let tabName = cert?.subject?.cn || "";
if (cert && !tabName) {
// No common name, use the value of the last item in the cert's entries.
tabName = cert.subject.entries?.slice(-1)[1] || "";
}
if (!cert) {
return {

Просмотреть файл

@ -32,7 +32,14 @@ export class CertificateTabsSection extends HTMLElement {
createTabSection(tabName, i) {
let tab = document.createElement("button");
tab.textContent = tabName;
if (tabName) {
tab.textContent = tabName;
} else {
tab.setAttribute(
"data-l10n-id",
"certificate-viewer-unknown-group-label"
);
}
tab.setAttribute("id", normalizeToKebabCase(tabName));
tab.setAttribute("aria-controls", "panel" + i);
tab.setAttribute("idnumber", i);

Просмотреть файл

@ -52,16 +52,28 @@ export class InfoGroup extends HTMLElement {
return;
}
let issuerCommonName = this.shadowRoot
.querySelector(".common-name")
.shadowRoot.querySelector(".info");
let issuerLabelElement =
this.shadowRoot.querySelector(".common-name") ||
this.shadowRoot.querySelector(".organizational-unit");
issuerLabelElement = issuerLabelElement?.shadowRoot.querySelector(".info");
if (!issuerLabelElement) {
return;
}
let link = document.createElement("a");
link.textContent = issuerCommonName.textContent;
link.textContent = issuerLabelElement.textContent;
if (!link.textContent) {
link.setAttribute(
"data-l10n-id",
"certificate-viewer-unknown-group-label"
);
}
link.setAttribute("href", "#");
issuerCommonName.textContent = "";
issuerCommonName.appendChild(link);
issuerLabelElement.textContent = "";
issuerLabelElement.appendChild(link);
link.addEventListener("click", () => {
let id = normalizeToKebabCase(link.textContent);

Просмотреть файл

@ -4,6 +4,7 @@ support-files =
adjustedCerts.js
[browser_aboutcertificateviewer.js]
[browser_checkLongHex.js]
[browser_checkMissingCommonName.js]
[browser_checkNonEmptyFields.js]
[browser_checkNonRepeatedCertTabs.js]
[browser_checkNonUndefinedStrings.js]

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -107,10 +107,16 @@ certificate-viewer-critical-extension =
certificate-viewer-export = Export
.download = { $fileName }.pem
##
# Label for a tab where we haven't found a better label:
certificate-viewer-unknown-group-label = (unknown)
## Labels for tabs displayed in stand-alone about:certificate page
certificate-viewer-tab-mine = Your Certificates
certificate-viewer-tab-people = People
certificate-viewer-tab-servers = Servers
certificate-viewer-tab-ca = Authorities
certificate-viewer-tab-unkonwn = Unknown
certificate-viewer-tab-unkonwn = Unknown