Roxen.git/
server/
etc/
modules/
Roxen.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2007-10-17
2007-10-17 14:13:14 by Henrik Grubbström (Grubba) <grubba@grubba.org>
266e2b1d5e945e324a32726e10726a65ad2eb00e (
31
lines) (+
30
/-
1
)
[
Show
|
Annotate
]
Branch:
5.2
Added encode_xml_invalids().
Rev: server/etc/modules/Roxen.pmod:1.226
1:
// This is a roxen pike module. Copyright © 1999 - 2004, Roxen IS. //
-
// $Id: Roxen.pmod,v 1.
225
2007/
02
/
07
14:
35
:
57
mast
Exp $
+
// $Id: Roxen.pmod,v 1.
226
2007/
10
/
17
14:
13
:
14
grubba
Exp $
#include <roxen.h> #include <config.h>
2191:
else return 0; }
+
static constant xml_invalids = ({
+
0, 1, 2, 3, 4, 5, 6, 7,
+
8, 11, 12, 14, 15,
+
16, 17, 18, 19, 20, 21, 22, 23,
+
24, 25, 26, 27, 28, 29, 30, 31,
+
127
+
});
+
+
static constant xml_printables = ({
+
0x2400, 0x2401, 0x2402, 0x2403, 0x2404, 0x2405, 0x2406, 0x2407,
+
0x2408, 0x240b, 0x240c, 0x240e, 0x240f,
+
0x2410, 0x2411, 0x2412, 0x2413, 0x2414, 0x2415, 0x2416, 0x2417,
+
0x2418, 0x2419, 0x241a, 0x241b, 0x241c, 0x241d, 0x241e, 0x241f,
+
0x2421,
+
});
+
+
string encode_xml_invalids(string s)
+
//! Remap control characters not valid in XML-documents to their
+
//! corresponding printable code points (@tt{U2400 - U2421@}).
+
{
+
return replace(s, xml_invalids, xml_printables);
+
}
+
//! Encode a single segment of @[roxen_encode()]. //! //! See @[roxen_encode()] for details.
2236:
case "html": return html_encode_string (val);
+
case "invalids":
+
case "xmlinvalids":
+
case "xml-invalids":
+
return encode_xml_invalids(val);
+
case "wml": return replace(html_encode_string(val), "$", "$$");