diff --git a/php/utils/utils.php b/php/utils/utils.php index 0ea7fa9..1c5d40e 100644 --- a/php/utils/utils.php +++ b/php/utils/utils.php @@ -148,4 +148,16 @@ return $links; } + /** + * Convert special characters to html entities. + */ + function html_sanitize( + string $str, int $flags = ENT_QUOTES|ENT_SUBSTITUTE, + ?string $encoding = null, bool $double_encode = true + ) { + if ($str == "") { + return ""; + } + return htmlspecialchars($str, $flags, $encoding, $double_encode); + } ?> diff --git a/sites/+components/tbl_communities.php b/sites/+components/tbl_communities.php index 11759a8..24fffe2 100644 --- a/sites/+components/tbl_communities.php +++ b/sites/+components/tbl_communities.php @@ -53,16 +53,16 @@ // Escape external input. // Ternaries prevent passing null-equal strings, which produce warnings. - $id = htmlspecialchars($room->get_room_identifier()); - $language = $room->language_flag ? htmlspecialchars($room->language_flag) : ""; - $name = htmlspecialchars($room->name); - $desc = $room->description ? htmlspecialchars($room->description) : ""; - $users = htmlspecialchars($room->active_users); - $preview_link = htmlspecialchars($room->get_preview_url()); - $join_link = htmlspecialchars($room->get_join_url()); - // TODO: Do not forget to rename this escape when merging! - $token = htmlspecialchars($token); - $hostname = htmlspecialchars($hostname); + $id = html_sanitize($room->get_room_identifier()); + $language = html_sanitize($room->language_flag); + $name = html_sanitize($room->name); + $desc = html_sanitize($room->description); + $users = html_sanitize($room->active_users); + $preview_link = html_sanitize($room->get_preview_url()); + $join_link = html_sanitize($room->get_join_url()); + // TODO: Do not forget to rename this escape when mergig! + $token = html_sanitize($token); + $hostname = html_sanitize($hostname); ?>