mirror of
https://github.com/pi-hole/web.git
synced 2026-04-25 03:10:18 +01:00
Escape hostname to prevent XSS
Signed-off-by: yubiuser <github@yubiuser.dev>
This commit is contained in:
@@ -40,6 +40,20 @@ function in_array (val, tab)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Function to escape HTML characters
|
||||
function escape_html(str)
|
||||
-- Replace special characters with HTML entities
|
||||
str = str:gsub("&", "&")
|
||||
str = str:gsub("<", "<")
|
||||
str = str:gsub(">", ">")
|
||||
str = str:gsub('"', """)
|
||||
str = str:gsub("'", "'")
|
||||
return str
|
||||
end
|
||||
|
||||
-- Sanitize hostname
|
||||
hostname = escape_html(hostname)
|
||||
|
||||
-- Variable to check if user is already authenticated
|
||||
is_authenticated = mg.request_info.is_authenticated
|
||||
|
||||
|
||||
Reference in New Issue
Block a user