From d8f32afeb01910f9b4a6272763e8d8e84f150c8c Mon Sep 17 00:00:00 2001 From: Trinity Pointard Date: Mon, 11 Jun 2018 16:05:18 +0200 Subject: [PATCH] allow html on user.summary --- src/models/users.rs | 11 ++++++----- templates/users/details.html.tera | 2 +- templates/users/followers.html.tera | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/models/users.rs b/src/models/users.rs index 1b58710f..86771548 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -45,6 +45,7 @@ use models::{ posts::Post }; use schema::users; +use safe_string::SafeString; pub const AUTH_COOKIE: &'static str = "user_id"; @@ -56,7 +57,7 @@ pub struct User { pub outbox_url: String, pub inbox_url: String, pub is_admin: bool, - pub summary: String, + pub summary: SafeString, pub email: Option, pub hashed_password: Option, pub instance_id: i32, @@ -75,7 +76,7 @@ pub struct NewUser { pub outbox_url: String, pub inbox_url: String, pub is_admin: bool, - pub summary: String, + pub summary: SafeString, pub email: Option, pub hashed_password: Option, pub instance_id: i32, @@ -200,7 +201,7 @@ impl User { outbox_url: acct["outbox"].as_str().unwrap().to_string(), inbox_url: acct["inbox"].as_str().unwrap().to_string(), is_admin: false, - summary: acct["summary"].as_str().unwrap().to_string(), + summary: SafeString::new(&acct["summary"].as_str().unwrap().to_string()), email: None, hashed_password: None, instance_id: instance.id, @@ -371,7 +372,7 @@ impl APActor for User { } fn get_summary(&self) -> String { - self.summary.clone() + self.summary.get().clone() } fn get_instance(&self, conn: &PgConnection) -> Instance { @@ -561,7 +562,7 @@ impl NewUser { outbox_url: String::from(""), inbox_url: String::from(""), is_admin: is_admin, - summary: summary, + summary: SafeString::new(&summary), email: Some(email), hashed_password: Some(password), instance_id: instance_id, diff --git a/templates/users/details.html.tera b/templates/users/details.html.tera index ca681b28..d225a300 100644 --- a/templates/users/details.html.tera +++ b/templates/users/details.html.tera @@ -28,7 +28,7 @@
- {{ user.summary }} + {{ user.summary | safe }}
{% if recents | length != 0 %} diff --git a/templates/users/followers.html.tera b/templates/users/followers.html.tera index ed6a8244..5d6a956e 100644 --- a/templates/users/followers.html.tera +++ b/templates/users/followers.html.tera @@ -23,7 +23,7 @@ {% for follower in followers %}

{{ follower.display_name }} — @{{ follower.fqn }}

-

{{ follower.summary }}

+

{{ follower.summary | safe }}

{% endfor %}