mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
23 lines
1.2 KiB
V
23 lines
1.2 KiB
V
import encoding.html
|
|
|
|
fn test_unescape_html() {
|
|
assert html.unescape('<>&') == '<>&'
|
|
assert html.unescape('No change') == 'No change'
|
|
assert html.unescape('<b>Bold text</b>') == '<b>Bold text</b>'
|
|
assert html.unescape('<img />') == '<img />'
|
|
assert html.unescape('' onmouseover='alert(1)'') == "' onmouseover='alert(1)'"
|
|
assert html.unescape('<a href='http://www.example.com'>link</a>') == "<a href='http://www.example.com'>link</a>"
|
|
assert html.unescape('<script>alert('hello');</script>') == "<script>alert('hello');</script>"
|
|
// Cases obtained from:
|
|
// https://github.com/apache/commons-lang/blob/master/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
|
|
assert html.unescape('plain text') == 'plain text'
|
|
assert html.unescape('') == ''
|
|
assert html.unescape('bread & butter') == 'bread & butter'
|
|
assert html.unescape('"bread" & butter') == '"bread" & butter'
|
|
assert html.unescape('greater than >') == 'greater than >'
|
|
assert html.unescape('< less than') == '< less than'
|
|
// Leave accents as-is
|
|
assert html.escape('café') == 'café'
|
|
assert html.escape('<p>façade</p>') == '<p>façade</p>'
|
|
}
|