???? ????????, ???????????? ???????
???? ????? ????? ?? ?????? ???? ???
?????:????? ????? ???????/?????
local
p
=
{}
local
html_entities
=
{
[
"""
]
=
'"'
,
[
"'"
]
=
"'"
,
[
"&"
]
=
"&"
,
[
"<"
]
=
"<"
,
[
">"
]
=
">"
,
[
"'"
]
=
"'"
}
function
p
.
decode_html_entities
(
frame
)
str
=
frame
.
args
.
string
return
p
.
decode_html_entities_internal
(
str
)
end
function
p
.
decode_html_entities_internal
(
str
)
-- First, decode any percent-encoded characters
str
=
str
:
gsub
(
"%%(%x%x)"
,
function
(
hex
)
return
string.char
(
tonumber
(
hex
,
16
))
end
)
-- Then, decode HTML entities
str
=
str
:
gsub
(
"(&.-;)"
,
function
(
entity
)
return
html_entities
[
entity
]
or
entity
end
)
return
str
end
return
p