Do not build SiteSpecific file when regex is invalid

This commit is contained in:
Quentin Rameau 2017-04-28 13:09:39 +02:00
parent 3c2c0a6525
commit 0d1e670ac3
1 changed files with 10 additions and 9 deletions

19
surf.c
View File

@ -299,26 +299,28 @@ setup(void)
gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy)); gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
for (i = 0; i < LENGTH(certs); ++i) { for (i = 0; i < LENGTH(certs); ++i) {
if (regcomp(&(certs[i].re), certs[i].regex, REG_EXTENDED)) { if (!regcomp(&(certs[i].re), certs[i].regex, REG_EXTENDED)) {
certs[i].file = g_strconcat(certdir, "/", certs[i].file,
NULL);
} else {
fprintf(stderr, "Could not compile regex: %s\n", fprintf(stderr, "Could not compile regex: %s\n",
certs[i].regex); certs[i].regex);
certs[i].regex = NULL; certs[i].regex = NULL;
} }
certs[i].file = g_strconcat(certdir, "/", certs[i].file, NULL);
} }
if (!stylefile) { if (!stylefile) {
styledir = buildpath(styledir); styledir = buildpath(styledir);
for (i = 0; i < LENGTH(styles); ++i) { for (i = 0; i < LENGTH(styles); ++i) {
if (regcomp(&(styles[i].re), styles[i].regex, if (!regcomp(&(styles[i].re), styles[i].regex,
REG_EXTENDED)) { REG_EXTENDED)) {
fprintf(stderr, styles[i].file = g_strconcat(styledir, "/",
"Could not compile regex: %s\n", styles[i].file, NULL);
} else {
fprintf(stderr, "Could not compile regex: %s\n",
styles[i].regex); styles[i].regex);
styles[i].regex = NULL; styles[i].regex = NULL;
} }
styles[i].file = g_strconcat(styledir, "/",
styles[i].file, NULL);
} }
g_free(styledir); g_free(styledir);
} else { } else {
@ -336,8 +338,7 @@ setup(void)
uriparams[i].config[j] = defconfig[j]; uriparams[i].config[j] = defconfig[j];
} }
} else { } else {
fprintf(stderr, fprintf(stderr, "Could not compile regex: %s\n",
"Could not compile regex: %s\n",
uriparams[i].uri); uriparams[i].uri);
uriparams[i].uri = NULL; uriparams[i].uri = NULL;
} }