Fix HTML encoding in templating (#404)

This commit is contained in:
Nick Lowery 2022-05-20 23:28:31 -06:00 committed by GitHub
parent 7e07ca3df1
commit 322aa97a18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 33 additions and 47 deletions

View file

@ -1,5 +1,4 @@
// CRATES
use crate::esc;
use crate::utils::{
catch_random, error, filter_posts, format_num, format_url, get_filters, param, redirect, rewrite_urls, setting, template, val, Post, Preferences, Subreddit,
};
@ -11,7 +10,7 @@ use time::{Duration, OffsetDateTime};
// STRUCTS
#[derive(Template)]
#[template(path = "subreddit.html", escape = "none")]
#[template(path = "subreddit.html")]
struct SubredditTemplate {
sub: Subreddit,
posts: Vec<Post>,
@ -28,7 +27,7 @@ struct SubredditTemplate {
}
#[derive(Template)]
#[template(path = "wiki.html", escape = "none")]
#[template(path = "wiki.html")]
struct WikiTemplate {
sub: String,
wiki: String,
@ -38,7 +37,7 @@ struct WikiTemplate {
}
#[derive(Template)]
#[template(path = "wall.html", escape = "none")]
#[template(path = "wall.html")]
struct WallTemplate {
title: String,
sub: String,
@ -408,9 +407,9 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result<Subreddit, String> {
let icon = if community_icon.is_empty() { val(&res, "icon_img") } else { community_icon.to_string() };
Ok(Subreddit {
name: esc!(&res, "display_name"),
title: esc!(&res, "title"),
description: esc!(&res, "public_description"),
name: val(&res, "display_name"),
title: val(&res, "title"),
description: val(&res, "public_description"),
info: rewrite_urls(&val(&res, "description_html")),
// moderators: moderators_list(sub, quarantined).await.unwrap_or_default(),
icon: format_url(&icon),