chiark / gitweb /
correct base64 changes
[disorder] / server / cgi.c
index ce04563575f7a09d5a30071e986bae06f32d7d5a..5e475edb025c1b22a4c832387114a224ad2dc5e5 100644 (file)
@@ -52,7 +52,7 @@
 #include "cgi.h"
 #include "printf.h"
 #include "mime.h"
-#include "utf8.h"
+#include "unicode.h"
 
 struct kvp *cgi_args;
 
@@ -187,8 +187,8 @@ void cgi_parse(void) {
   else
     fatal(0, "unknown request method %s", p);
   for(k = cgi_args; k; k = k->next)
-    if(!validutf8(k->name)
-       || !validutf8(k->value))
+    if(!utf8_valid(k->name, strlen(k->name))
+       || !utf8_valid(k->value, strlen(k->value)))
       fatal(0, "invalid UTF-8 sequence in cgi argument");
 }
 
@@ -225,7 +225,7 @@ char *cgi_sgmlquote(const char *s, int raw) {
   int n;
 
   if(!raw) {
-    if(!(ucs = utf82ucs4(s))) exit(EXIT_FAILURE);
+    if(!(ucs = utf8_to_utf32(s, strlen(s), 0))) exit(EXIT_FAILURE);
   } else {
     ucs = xmalloc_noptr((strlen(s) + 1) * sizeof(uint32_t));
     for(n = 0; s[n]; ++n)
@@ -585,9 +585,19 @@ const char *cgi_label(const char *key) {
 
   read_options();
   if(!(label = kvp_get(labels, key))) {
-    if((label = strchr(key, '.')))
+    /* No label found */
+    if(!strncmp(key, "images.", 7)) {
+      static const char *url_static;
+      /* images.X defaults to <url.static>X.png */
+
+      if(!url_static)
+       url_static = cgi_label("url.static");
+      byte_xasprintf((char **)&label, "%s%s.png", url_static, key + 7);
+    } else if((label = strchr(key, '.')))
+      /* X.Y defaults to Y */
       ++label;
     else
+      /* otherwise default to label name */
       label = key;
   }
   return label;