perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steve.sparl...@ps.ge.com
Subject [mp2.0] Win32 ENV still not compatible with mod_cgi
Date Tue, 06 May 2003 10:33:16 GMT
1. Problem Description:

 %ENV still not compatible with mod_cgi regarding mixed case variable names.

 I had previously reported this problem with mod_perl-1.99_08 and I was
delighted to find an update in
 mod_perl-1.99_09 regarding Win32 env. However, the fix does not address the
problem.

The following diff shows what I've done in my local version to make it
compatible. I know that it probably
does not address the root cause, but it fixes the key name at the lowest
possible level to:-

a) Ensure that the first character of the name is not a digit (re mod_cgi)
b) All non alpha-numeric characters are replaced with '_' underscores (re
mod_cgi)
c) On Win32, all characters are UPPERCASE (implicitly done in mod_cgi by
invoking CreateProcess(...) with the env block)




--- modperl_env_orig.c	Tue Oct 22 03:42:04 2002
+++ modperl_env.c	Tue May 06 11:05:11 2003
@@ -4,22 +4,50 @@
 #define EnvMgLen SvMAGIC((SV*)ENVHV)->mg_len
 
 static MP_INLINE
+char *modperl_env_key_fixup(const char *inKey)
+{
+    char *outKey = strdup(inKey);
+    char *whack = outKey;
+
+    if (apr_isdigit(*whack)) {
+        *whack++ = '_';
+    }
+
+    while (*whack) {
+        if (!apr_isalnum(*whack) && *whack != '_') {
+            *whack = '_';
+        }
+#ifdef ENV_IS_CASELESS /* i.e. WIN32 */
+        else {
+            *whack = apr_toupper(*whack);
+        }
+#endif
+
+        ++whack;
+    }
+
+    return outKey;
+}
+
+static MP_INLINE
 void modperl_env_hv_store(pTHX_ HV *hv, apr_table_entry_t *elt)
 {
-    I32 klen = strlen(elt->key);
-    SV **svp = hv_fetch(hv, elt->key, klen, FALSE);
+    char *key = modperl_env_key_fixup(elt->key); /* Emulate CGI / Win32
behaviour */
+    I32 klen = strlen(key);
+    SV **svp = hv_fetch(hv, key, klen, FALSE);
 
     if (svp) {
         sv_setpv(*svp, elt->val);
     }
     else {
         SV *sv = newSVpv(elt->val, 0);
-        hv_store(hv, elt->key, klen, sv, FALSE);
-        modperl_envelem_tie(sv, elt->key, klen);
+        hv_store(hv, key, klen, sv, FALSE);
+        modperl_envelem_tie(sv, key, klen);
         svp = &sv;
     }
 
     SvTAINTED_on(*svp);
+    free(key);
 }
 
 typedef struct {






2. Used Components and their Configuration:

*** using lib/Apache/BuildConfig.pm
*** Makefile.PL options:
  MP_AP_PREFIX   => C:/Apache2
  MP_COMPAT_1X   => 1
  MP_GENERATE_XS => 1
  MP_LIBNAME     => mod_perl
  MP_USE_DSO     => 1
  MP_USE_STATIC  => 1


*** C:/Apache2/bin/Apache.exe -V
Server version: Apache/2.0.45
Server built:   Apr  2 2003 16:52:20
Server's Module Magic Number: 20020903:0
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/winnt"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/apache"
 -D SUEXEC_BIN="/apache/bin/suexec"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error.log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"


*** C:\Perl\bin\perl.exe -V
Summary of my perl5 (revision 5 version 8 subversion 0) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth="C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib"
"C:\Program Files\Microsoft Visual Studio\VC98\lib" "C:\Perl\lib\CORE"
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl): 
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
  Locally applied patches:
  	ActivePerl Build 805
  Built under MSWin32
  Compiled at Feb  4 2003 18:08:02
  %ENV:
    PERL_LWP_USE_HTTP_10="1"
  @INC:
    C:/Perl/lib
    C:/Perl/site/lib
    .


3. This is the core dump trace: (if you get a core dump):

  [CORE TRACE COMES HERE]

This report was generated by t/REPORT on Tue May  6 10:17:01 2003 GMT.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message