Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle unset cookies correctly #5023

Merged
merged 1 commit into from
Jan 24, 2023
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
10 changes: 9 additions & 1 deletion ietf/static/js/document_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion ietf/templates/doc/document_html.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down