From 4f029e11e3e9f89c9f6f82f230a4311a2f1310b0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 18 Sep 2024 16:47:53 +0200 Subject: [PATCH] Make `json_encode` filter "safe" --- src/web/page/templates.rs | 6 ++++-- templates/rustdoc/topbar.html | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/web/page/templates.rs b/src/web/page/templates.rs index 9da280509..7d3cffbd0 100644 --- a/src/web/page/templates.rs +++ b/src/web/page/templates.rs @@ -234,8 +234,10 @@ pub mod filters { Ok(value.split(pat).next()) } - pub fn json_encode(value: &T) -> rinja::Result { - Ok(serde_json::to_string(value).expect("`encode_json` failed")) + pub fn json_encode(value: &T) -> rinja::Result> { + Ok(Safe( + serde_json::to_string(value).expect("`encode_json` failed"), + )) } pub fn rest_menu_url(current_target: &str, inner_path: &str) -> rinja::Result { diff --git a/templates/rustdoc/topbar.html b/templates/rustdoc/topbar.html index 7eb80f079..b00e2fbe9 100644 --- a/templates/rustdoc/topbar.html +++ b/templates/rustdoc/topbar.html @@ -16,8 +16,8 @@ {# the only text that needs escaping in a {%- if krate is defined -%}