1
0
mirror of https://github.com/actix/examples synced 2024-11-23 14:31:07 +01:00

Escape HTML (#366)

This commit is contained in:
mattn 2020-09-15 01:02:57 +09:00 committed by GitHub
parent 49e29a5751
commit e3c6a1ec07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -15,7 +15,7 @@ futures = "0.3.1"
log = "0.4.3"
serde = { version = "1.0.69", features = ["derive"] }
serde_json = "1.0.22"
tera = "1.0"
tera = "1.5.0"
[dependencies.diesel]
features = ["postgres", "r2d2"]

View File

@ -33,7 +33,14 @@ async fn main() -> io::Result<()> {
let app = move || {
debug!("Constructing the App");
let templates: Tera = Tera::new("templates/**/*").unwrap();
let mut templates = match Tera::new("templates/**/*") {
Ok(t) => t,
Err(e) => {
println!("Parsing error(s): {}", e);
::std::process::exit(1);
}
};
templates.autoescape_on(vec!["tera"]);
let session_store = CookieSession::signed(SESSION_SIGNING_KEY).secure(false);

View File

@ -52,7 +52,7 @@
{% else %}
<form action="/todo/{{task.id}}" class="link" method="post">
<input type="hidden" name="_method" value="put" />
<button type="submit" class="link">{{ task.description }}</button>
<button type="submit" class="link">{{task.description}}</button>
</form>
{% endif %}
</li>