X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/bc4721da0441a30822225c51b250be4cc5f8af24..c7bdebaaf134729356852918b387071c92f85e72:/IkiWiki/Wrapper.pm diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm index ffbaf9908..69500029c 100644 --- a/IkiWiki/Wrapper.pm +++ b/IkiWiki/Wrapper.pm @@ -63,7 +63,8 @@ EOF if (ref $config{ENV} eq 'HASH') { foreach my $key (keys %{$config{ENV}}) { my $val=$config{ENV}{$key}; - $val =~ s/([\\"])/\\$1/g; + utf8::encode($val) if utf8::is_utf8($val); + $val =~ s/([^A-Za-z0-9])/sprintf '""\\x%02x""', ord($1)/ge; $envsize += 1; $envsave.=<<"EOF"; addenv("$key", "$val"); @@ -188,16 +189,23 @@ int i=0; void addenv(char *var, char *val) { char *s=malloc(strlen(var)+1+strlen(val)+1); - if (!s) + if (!s) { perror("malloc"); - sprintf(s, "%s=%s", var, val); - newenviron[i++]=s; + exit(1); + } + else { + sprintf(s, "%s=%s", var, val); + newenviron[i++]=s; + } } void set_cgilock_fd (int lockfd) { - char *fd_s=malloc(8); + char fd_s[12]; sprintf(fd_s, "%i", lockfd); - setenv("IKIWIKI_CGILOCK_FD", fd_s, 1); + if (setenv("IKIWIKI_CGILOCK_FD", fd_s, 1) != 0) { + perror("setenv"); + exit(1); + } } int main (int argc, char **argv) {