diff options
author | Simon McVittie <smcv@debian.org> | 2014-09-15 09:44:51 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2014-09-15 09:44:51 +0100 |
commit | 9d928bd69496648cd7a2d4542a2d533992c01757 (patch) | |
tree | ae1d265741d944cdc63574ad78cbea3d11d397d5 /IkiWiki | |
parent | f574bc2ed470b60f576a2906998bc7c129f2f983 (diff) | |
parent | 29e80b4eedadc2afd3f9f36d215076c82982971b (diff) | |
download | ikiwiki-9d928bd69496648cd7a2d4542a2d533992c01757.tar ikiwiki-9d928bd69496648cd7a2d4542a2d533992c01757.tar.gz |
Merge remote-tracking branch 'jcflack/early-env'
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Wrapper.pm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm index b46bc6aa9..4c99cdaa0 100644 --- a/IkiWiki/Wrapper.pm +++ b/IkiWiki/Wrapper.pm @@ -52,6 +52,7 @@ sub gen_wrapper () { HTTP_COOKIE REMOTE_USER HTTPS REDIRECT_STATUS HTTP_HOST SERVER_PORT HTTPS HTTP_ACCEPT REDIRECT_URL} if $config{cgi}; + my $envsize=$#envsave; my $envsave=""; foreach my $var (@envsave) { $envsave.=<<"EOF"; @@ -59,6 +60,18 @@ sub gen_wrapper () { addenv("$var", s); EOF } + if (ref $config{ENV} eq 'HASH') { + foreach my $key (keys %{$config{ENV}}) { + my $val=$config{ENV}{$key}; + 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"); +EOF + } + delete $config{ENV}; + } my @wrapper_hooks; run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() }); @@ -171,7 +184,7 @@ EOF #include <sys/file.h> extern char **environ; -char *newenviron[$#envsave+7]; +char *newenviron[$envsize+7]; int i=0; void addenv(char *var, char *val) { |