diff --git a/Cargo.lock b/Cargo.lock index 961a9dafd..97d0fe687 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,9 +166,9 @@ dependencies = [ [[package]] name = "askama" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4744ed2eef2645831b441d8f5459689ade2ab27c854488fbab1fbe94fce1a7" +checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4" dependencies = [ "askama_derive", "itoa 1.0.15", @@ -179,9 +179,9 @@ dependencies = [ [[package]] name = "askama_derive" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d661e0f57be36a5c14c48f78d09011e67e0cb618f269cca9f2fd8d15b68c46ac" +checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f" dependencies = [ "askama_parser", "basic-toml", @@ -196,9 +196,9 @@ dependencies = [ [[package]] name = "askama_parser" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f" +checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358" dependencies = [ "memchr", "serde", diff --git a/Cargo.toml b/Cargo.toml index fe3d83db8..81e57899a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,7 @@ tempfile = "3.1.0" fn-error-context = "0.2.0" # Templating -askama = "0.13.1" +askama = "0.14.0" walkdir = "2" # Date and Time utilities diff --git a/src/web/highlight.rs b/src/web/highlight.rs index 7b8eb83d5..fd92d1993 100644 --- a/src/web/highlight.rs +++ b/src/web/highlight.rs @@ -82,7 +82,7 @@ pub fn with_lang(lang: Option<&str>, code: &str, default: Option<&str>) -> Strin } else { log::error!("failed while highlighting code: {err:?}"); } - crate::web::page::templates::filters::escape_html(code) + crate::web::page::templates::filters::escape_html(code, &()) .map(|s| s.to_string()) .unwrap_or_default() } diff --git a/src/web/page/templates.rs b/src/web/page/templates.rs index 59b069e0d..cca91edb8 100644 --- a/src/web/page/templates.rs +++ b/src/web/page/templates.rs @@ -88,12 +88,13 @@ impl TemplateData { } pub mod filters { + use askama::Values; use askama::filters::Safe; use chrono::{DateTime, Utc}; use std::borrow::Cow; // Copied from `tera`. - pub fn escape_html(input: &str) -> askama::Result> { + pub fn escape_html<'a>(input: &'a str, _: &dyn Values) -> askama::Result> { if !input.chars().any(|c| "&<>\"'/".contains(c)) { return Ok(Cow::Borrowed(input)); } @@ -115,7 +116,7 @@ pub mod filters { } // Copied from `tera`. - pub fn escape_xml(input: &str) -> askama::Result> { + pub fn escape_xml<'a>(input: &'a str, _: &dyn Values) -> askama::Result> { if !input.chars().any(|c| "&<>\"'".contains(c)) { return Ok(Cow::Borrowed(input)); } @@ -135,11 +136,11 @@ pub mod filters { /// Prettily format a timestamp // TODO: This can be replaced by chrono - pub fn timeformat(value: &DateTime) -> askama::Result { + pub fn timeformat(value: &DateTime, _: &dyn Values) -> askama::Result { Ok(crate::web::duration_to_str(*value)) } - pub fn format_secs(mut value: f32) -> askama::Result { + pub fn format_secs(mut value: f32, _: &dyn Values) -> askama::Result { const TIMES: &[&str] = &["seconds", "minutes", "hours"]; let mut chosen_time = &TIMES[0]; @@ -166,6 +167,7 @@ pub mod filters { #[allow(clippy::unnecessary_wraps)] pub fn dedent>>( value: T, + _: &dyn Values, levels: I, ) -> askama::Result { let string = value.to_string(); @@ -200,7 +202,11 @@ pub mod filters { Ok(unindented) } - pub fn highlight(code: impl std::fmt::Display, lang: &str) -> askama::Result> { + pub fn highlight( + code: impl std::fmt::Display, + _: &dyn Values, + lang: &str, + ) -> askama::Result> { let highlighted_code = crate::web::highlight::with_lang(Some(lang), &code.to_string(), None); Ok(Safe(format!( @@ -209,7 +215,7 @@ pub mod filters { ))) } - pub fn round(value: &f32, precision: u32) -> askama::Result { + pub fn round(value: &f32, _: &dyn Values, precision: u32) -> askama::Result { let multiplier = if precision == 0 { 1.0 } else { @@ -218,11 +224,18 @@ pub mod filters { Ok(((multiplier * *value).round() / multiplier).to_string()) } - pub fn split_first<'a>(value: &'a str, pat: &str) -> askama::Result> { + pub fn split_first<'a>( + value: &'a str, + _: &dyn Values, + pat: &str, + ) -> askama::Result> { Ok(value.split(pat).next()) } - pub fn json_encode(value: &T) -> askama::Result> { + pub fn json_encode( + value: &T, + _: &dyn Values, + ) -> askama::Result> { Ok(Safe( serde_json::to_string(value).expect("`encode_json` failed"), )) diff --git a/templates/releases/search_results.html b/templates/releases/search_results.html index f411d3267..696621e40 100644 --- a/templates/releases/search_results.html +++ b/templates/releases/search_results.html @@ -6,7 +6,7 @@ {%- endblock header -%} {%- block topbar -%} - {% let search_query = search_query %} + {% let search_query = &search_query %} {%- include "header/topbar.html" -%} {%- endblock topbar -%}