mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-28 14:38:52 +00:00
Remove HTML code of conversation names
This commit is contained in:
parent
8a2b618648
commit
82eb997e2d
@ -2,12 +2,13 @@
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::helpers::{user_helper, conversations_helper};
|
||||
use crate::data::new_conversation::NewConversation;
|
||||
use crate::api_data::res_create_conversation::ResCreateConversation;
|
||||
use crate::api_data::conversation_api::ConversationAPI;
|
||||
use crate::api_data::res_create_conversation::ResCreateConversation;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::data::new_conversation::NewConversation;
|
||||
use crate::helpers::{conversations_helper, user_helper};
|
||||
use crate::utils::string_utils::remove_html_nodes;
|
||||
|
||||
/// Create a new conversation
|
||||
pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
@ -110,8 +111,7 @@ pub fn update_settings(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let name = if name.eq("false") || name.is_empty() {
|
||||
None
|
||||
} else {
|
||||
// TODO : remove HTML nodes
|
||||
Some(name)
|
||||
Some(remove_html_nodes(&name))
|
||||
};
|
||||
|
||||
conversations_helper::set_name(conv_id, name)?;
|
||||
|
@ -5,4 +5,5 @@
|
||||
pub mod crypt_utils;
|
||||
pub mod user_data_utils;
|
||||
pub mod virtual_directories_utils;
|
||||
pub mod date_utils;
|
||||
pub mod date_utils;
|
||||
pub mod string_utils;
|
19
src/utils/string_utils.rs
Normal file
19
src/utils/string_utils.rs
Normal file
@ -0,0 +1,19 @@
|
||||
//! # String utilities
|
||||
//!
|
||||
//! This module contains utilities that can be used accross all the application
|
||||
|
||||
/// Escape an HTML string
|
||||
///
|
||||
/// Removes the HTML code included inside a string
|
||||
///
|
||||
/// ```
|
||||
/// use comunic_server::utils::string_utils::remove_html_nodes;
|
||||
///
|
||||
/// let s1 = "<b>hello world</b>";
|
||||
/// let res1 = remove_html_nodes(s1);
|
||||
/// assert_eq!(res1, "<b>hello world</b>");
|
||||
/// ```
|
||||
pub fn remove_html_nodes(input: &str) -> String {
|
||||
input.replace("<", "<")
|
||||
.replace(">", ">")
|
||||
}
|
Loading…
Reference in New Issue
Block a user