comparison src/c/lacweb.c @ 135:b1cfe49ce692

Proper escaping of cdata
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Jul 2008 13:33:56 -0400
parents 6230bdd122e7
children 133fa2d51bb4
comparison
equal deleted inserted replaced
134:18299126a343 135:b1cfe49ce692
69 69
70 void lw_write(lw_context ctx, const char* s) { 70 void lw_write(lw_context ctx, const char* s) {
71 lw_check(ctx, strlen(s)); 71 lw_check(ctx, strlen(s));
72 lw_write_unsafe(ctx, s); 72 lw_write_unsafe(ctx, s);
73 } 73 }
74
74 75
75 char *lw_Basis_attrifyInt(lw_Basis_int n) { 76 char *lw_Basis_attrifyInt(lw_Basis_int n) {
76 return "0"; 77 return "0";
77 } 78 }
78 79
205 } 206 }
206 207
207 lw_Basis_string lw_unurlifyString(char **s) { 208 lw_Basis_string lw_unurlifyString(char **s) {
208 return ""; 209 return "";
209 } 210 }
211
212
213 char *lw_Basis_htmlifyString(lw_Basis_string s) {
214 return "";
215 }
216
217 void lw_Basis_htmlifyString_w(lw_context ctx, lw_Basis_string s) {
218 lw_check(ctx, strlen(s) * 5);
219
220 for (; *s; s++) {
221 char c = *s;
222
223 switch (c) {
224 case '<':
225 lw_write_unsafe(ctx, "&lt;");
226 break;
227 case '&':
228 lw_write_unsafe(ctx, "&amp;");
229 break;
230 default:
231 if (isprint(c))
232 lw_writec_unsafe(ctx, c);
233 else {
234 lw_write_unsafe(ctx, "&#");
235 lw_Basis_attrifyInt_w_unsafe(ctx, c);
236 lw_writec_unsafe(ctx, ';');
237 }
238 }
239 }
240 }