1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

encoding.html: add escape() function (#16666)

This commit is contained in:
Subhomoy Haldar
2022-12-13 20:10:57 +00:00
committed by GitHub
parent 69f7c45bec
commit b07e447764
3 changed files with 44 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ import net.http
import net.urllib
import time
import json
import encoding.html
// A type which don't get filtered inside templates
pub type RawHtml = string
@@ -725,12 +726,5 @@ fn send_string(mut conn net.TcpConn, s string) ! {
// It used by `vlib/v/gen/c/str_intp.v:130` for string interpolation inside vweb templates
// TODO: move it to template render
fn filter(s string) string {
return s.replace_each([
'<',
'&lt;',
'"',
'&quot;',
'&',
'&amp;',
])
return html.escape(s)
}