fix: Handle unset cookies correctly (#5023)

Fixes #5015
This commit is contained in:
Lars Eggert 2023-01-24 17:02:21 +02:00 committed by GitHub
parent db3506e8c7
commit 61f7984d5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -49,13 +49,21 @@ document.addEventListener("DOMContentLoaded", function (event) {
// activate pref buttons selected by pref cookies or localStorage
const in_localStorage = ["deftab", "reflinks"];
const btn_pref = {
"sidebar": "on",
"deftab": "docinfo",
"htmlconf": "html",
"pagedeps": "reference",
"reflinks": "refsection"
};
document.querySelectorAll("#pref-tab-pane .btn-check")
.forEach(btn => {
const id = btn.id.replace("-radio", "");
const val = in_localStorage.includes(btn.name) ?
localStorage.getItem(btn.name) : cookies.get(btn.name);
if (val == id) {
if (val == id || ((val == undefined || val == null) &&
btn_pref[btn.name] == id)) {
btn.checked = true;
}

View file

@ -167,7 +167,7 @@
</span>
</p>
{% if request.COOKIES.htmlconf != 'html' and html %}
{% if request.COOKIES.htmlconf and request.COOKIES.htmlconf != 'html' and html %}
<div class="alert alert-info small">
You are viewing the legacy <code><a class="text-decoration-none text-reset" href="https://github.com/ietf-tools/rfc2html">rfc2html</a></code>
rendering of this document. Change the