Skip to content

Commit

Permalink
feat: sanitize html when saving
Browse files Browse the repository at this point in the history
  • Loading branch information
zrll12 committed Sep 8, 2024
1 parent 7eda311 commit 7933c68
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 1 deletion.
182 changes: 182 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ migration = {path = "migration"}
sea-orm = { version = "1.0.1", features = ["macros", "sqlx-postgres", "runtime-tokio-rustls"] }
futures = "0.3.30"
chrono = "0.4.38"
ammonia = "4.0.0"


[build-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion src/controller/survey/modify.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ammonia::clean;
use crate::controller::error::ErrorMessage;
use crate::model::generated::survey;
use crate::service::admin::AdminTokenInfo;
Expand Down Expand Up @@ -38,7 +39,7 @@ pub async fn create_survey(AdminTokenInfo(admin): AdminTokenInfo, Json(request):
id: NotSet,
title: Set(request.title),
budge: Set(request.budge),
description: Set(request.description),
description: Set(clean(&request.description)),
image: Set(request.image),
page: Set(request.page),
start_date: Set(request.start_date),
Expand Down

0 comments on commit 7933c68

Please sign in to comment.