webmcp
view framework/env/encode/html.lua @ 2:72860d232f32
Version 1.0.2
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
author | jbe/bsw |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
parents | 9fdfb27f8e67 |
children |
line source
1 --[[--
2 result = -- encoded string
3 encode.html(
4 str -- original string
5 )
7 This function replaces the special characters '<', '>', '&' and '"' by their HTML entities '<', '&rt;', '&' and '"'.
9 NOTE: ACCELERATED FUNCTION
10 Do not change unless also you also update webmcp_accelerator.c
12 --]]--
14 function encode.html(text)
15 -- TODO: perhaps filter evil control characters?
16 return (
17 string.gsub(
18 text, '[<>&"]',
19 function(char)
20 if char == '<' then
21 return "<"
22 elseif char == '>' then
23 return ">"
24 elseif char == '&' then
25 return "&"
26 elseif char == '"' then
27 return """
28 end
29 end
30 )
31 )
32 end