diff options
author | Adam Chlipala <adam@chlipala.net> | 2016-05-15 09:47:49 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2016-05-15 09:47:49 -0400 |
commit | d6453242560cfeaa31e74b2c77423b4ada288ac6 (patch) | |
tree | 1f28ac4db0a476a21e4234c38e19eb8ae8edf666 /src/c/urweb.c | |
parent | a0686c30f1315a6ca8c10acfca386df468f172a8 (diff) |
Support for <meta> tags
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r-- | src/c/urweb.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 7e535122..c23366fb 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3835,6 +3835,34 @@ uw_Basis_string uw_Basis_checkEnvVar(uw_context ctx, uw_Basis_string s) { return NULL; } +static int meta_format(const char *s) { + for (; *s; ++s) + if (!isalpha((int)*s) && *s != '-') + return 0; + + return 1; +} + +uw_Basis_string uw_Basis_blessMeta(uw_context ctx, uw_Basis_string s) { + if (!meta_format(s)) + uw_error(ctx, FATAL, "Meta name \"%s\" contains invalid character", uw_Basis_htmlifyString(ctx, s)); + + if (ctx->app->check_meta(s)) + return s; + else + uw_error(ctx, FATAL, "Disallowed meta name %s", uw_Basis_htmlifyString(ctx, s)); +} + +uw_Basis_string uw_Basis_checkMeta(uw_context ctx, uw_Basis_string s) { + if (!meta_format(s)) + return NULL; + + if (ctx->app->check_meta(s)) + return s; + else + return NULL; +} + uw_Basis_string uw_Basis_getHeader(uw_context ctx, uw_Basis_string name) { return uw_Basis_requestHeader(ctx, name); } |