commit - 6e1d6bccb3a2bc6497c88df19234d01b67463d09d521ff5f79d11d316966124d
commit + 38593aa7708aaf3555b8769576a06d7b98bd16f2e794700a37920a9cf375b9c1
blob - ea8e84670d9e4c80c9c355b0ffa17c99e7112d32538bfe9714a75b602a172242
blob + d75967e32aa3420e270c1c069bf43ed4e334e1b0243106a8f5ac05c9a29da554
--- lib/gotsys_conf.c
+++ lib/gotsys_conf.c
#include "media.h"
#include "gotwebd.h"
#include "gotsys.h"
+#include "utf8d.h"
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
const struct got_error *
gotsys_conf_validate_string(const char *s)
{
+ uint32_t cp, state = UTF8_ACCEPT;
int i;
for (i = 0; s[i] != '\0'; ++i) {
char x = s[i];
+ if (utf8_decode(&state, &cp, (unsigned char)x) == UTF8_REJECT) {
+ return got_error_msg(GOT_ERR_PARSE_CONFIG,
+ "invalid UTF-8 string");
+ }
+
/*
* Similar to gotwebd/parse.y allowed_in_string() while
- * allowing for spaces and tabs in quoted strings.
+ * allowing for UTF-8, spaces, and tabs in quoted strings.
*/
- if (isalnum((unsigned char)x) || x == ' ' || x == '\t' ||
+ if (isalnum((unsigned char)x) ||
+ ((unsigned char)x & 0x80) == 0x80 ||
+ x == ' ' || x == '\t' ||
(ispunct((unsigned char)x) && x != '(' && x != ')' &&
x != '{' && x != '}' &&
x != '!' && x != '=' && x != '#' &&
continue;
return got_error_fmt(GOT_ERR_PARSE_CONFIG,
- "character '%c' (0x%.2x) is not allowed in %s", x, x, s);
+ "character '%c' (0x%x) is not allowed in %s", x,
+ (unsigned char)x, s);
}
return NULL;