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,6 +1,5 @@
// CRATES
use crate::client::json;
use crate::esc;
use crate::server::RequestExt;
use crate::utils::{error, filter_posts, format_url, get_filters, param, template, Post, Preferences, User};
use askama::Template;
@ -9,7 +8,7 @@ use time::{macros::format_description, OffsetDateTime};
// STRUCTS
#[derive(Template)]
#[template(path = "user.html", escape = "none")]
#[template(path = "user.html")]
struct UserTemplate {
user: User,
posts: Vec<Post>,
@ -102,11 +101,11 @@ async fn user(name: &str) -> Result<User, String> {
// Parse the JSON output into a User struct
User {
name: res["data"]["name"].as_str().unwrap_or(name).to_owned(),
title: esc!(about("title")),
title: about("title"),
icon: format_url(&about("icon_img")),
karma: res["data"]["total_karma"].as_i64().unwrap_or(0),
created: created.format(format_description!("[month repr:short] [day] '[year repr:last_two]")).unwrap_or_default(),
banner: esc!(about("banner_img")),
banner: about("banner_img"),
description: about("public_description"),
}
})