httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r155821 - in httpd/apreq/branches/multi-env-unstable: ./ glue/perl/t/apreq/ glue/perl/t/response/TestAPI/ glue/perl/t/response/TestApReq/ glue/perl/xsbuilder/ glue/perl/xsbuilder/APR/Request/Cookie/ glue/perl/xsbuilder/APR/Request/Param/ include/
Date Tue, 01 Mar 2005 20:30:06 GMT
Author: joes
Date: Tue Mar  1 12:30:02 2005
New Revision: 155821

URL: http://svn.apache.org/viewcvs?view=rev&rev=155821
Log:
Add utf8 charset flag for params.

Modified:
    httpd/apreq/branches/multi-env-unstable/CHANGES
    httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/cgi.t
    httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/cookie.pm
    httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/param.pm
    httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/cookie.pm
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h
    httpd/apreq/branches/multi-env-unstable/include/apreq.h
    httpd/apreq/branches/multi-env-unstable/include/apreq_param.h

Modified: httpd/apreq/branches/multi-env-unstable/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/CHANGES?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/CHANGES (original)
+++ httpd/apreq/branches/multi-env-unstable/CHANGES Tue Mar  1 12:30:02 2005
@@ -4,6 +4,10 @@
 
 @section v2_05_dev Changes with libapreq2-2.05-dev
 
+
+- C API [joes]
+  Add utf8 charset flag for params.
+
 - C API [joes]
   Replace v->size with v->nlen + v->dlen.
   Added supporting apreq_value_table_add().

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/cgi.t
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/cgi.t?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/cgi.t (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/cgi.t Tue Mar  1 12:30:02 2005
@@ -249,11 +249,11 @@
     apreq_log("Fetching cookie $key");
     if ($cookies{$key}) {
         if ($test eq "bake") {
-            $cookies{$key}->tainted(0);
+            $cookies{$key}->is_tainted(0);
             $cookies{$key}->bake;
         }
         elsif ($test eq "bake2") {
-            $cookies{$key}->tainted(0);
+            $cookies{$key}->is_tainted(0);
             $cookies{$key}->bake2;
         }
         print "Content-Type: text/plain\n\n";

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/cookie.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/cookie.pm?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/cookie.pm (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/cookie.pm Tue Mar
 1 12:30:02 2005
@@ -47,9 +47,9 @@
     ok t_cmp join(" ", $jar->get("foo")), "1 3", '$jar->get("foo")';
 
     ok not defined $jar->cookie_class("APR::Request::Cookie");
-    ok t_cmp $_->tainted, 1, "is tainted: $_" for values %$jar;
-    $_->tainted(0) for values %$jar;
-    ok t_cmp $_->tainted, 0, "not tainted: $_" for values %$jar;
+    ok t_cmp $_->is_tainted, 1, "is tainted: $_" for values %$jar;
+    $_->is_tainted(0) for values %$jar;
+    ok t_cmp $_->is_tainted, 0, "not tainted: $_" for values %$jar;
 
     eval { $jar->cookie_class("APR::Request::Param") };
     ok t_cmp qr/^Usage/, $@, "Bad class name";

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/param.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/param.pm?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/param.pm (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestAPI/param.pm Tue Mar
 1 12:30:02 2005
@@ -47,9 +47,9 @@
     ok t_cmp join(" ", $args->get("foo")), "1 3", '$args->get("foo")';
 
     ok not defined $args->param_class("APR::Request::Param");
-    ok t_cmp $_->tainted, 1, "is tainted: $_" for values %$args;
-    $_->tainted(0) for values %$args;
-    ok t_cmp $_->tainted, 0, "not tainted: $_" for values %$args;
+    ok t_cmp $_->is_tainted, 1, "is tainted: $_" for values %$args;
+    $_->is_tainted(0) for values %$args;
+    ok t_cmp $_->is_tainted, 0, "not tainted: $_" for values %$args;
 
 
     eval { $args->param_class("APR::Request::Cookie") };

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/cookie.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/cookie.pm?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/cookie.pm (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/cookie.pm Tue Mar
 1 12:30:02 2005
@@ -22,11 +22,11 @@
 
     if ($key and $cookies{$key}) {
         if ($test eq "bake") {
-            $cookies{$key}->tainted(0);
+            $cookies{$key}->is_tainted(0);
             $cookies{$key}->bake;
         }
         elsif ($test eq "bake2") {
-            $cookies{$key}->tainted(0);
+            $cookies{$key}->is_tainted(0);
             $cookies{$key}->bake2;
         }
         $r->print($cookies{$key}->value);

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Cookie/Cookie.xs
Tue Mar  1 12:30:02 2005
@@ -285,7 +285,7 @@
     RETVAL
 
 IV
-tainted(obj, val=NULL)
+is_tainted(obj, val=NULL)
     APR::Request::Cookie obj
     SV *val
   PREINIT:

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
Tue Mar  1 12:30:02 2005
@@ -65,3 +65,458 @@
 
     return sv_bless(newRV_noinc(sv), SvSTASH(SvRV(rv)));
 }
+
+
+/* Upload-related stuff */
+#if 0
+
+static XS(apreq_xs_upload_link)
+{
+    dXSARGS;
+    MAGIC *mg;
+    void *env;
+    const char *name, *fname;
+    apr_bucket_brigade *bb;
+    apr_file_t *f;
+    apr_status_t s = APR_SUCCESS;
+    SV *sv, *obj;
+
+    if (items != 2 || !SvROK(ST(0)))
+        Perl_croak(aTHX_ "Usage: $upload->link($filename)");
+
+    if (SvTAINTED(ST(1)))
+        Perl_croak(aTHX_ "$upload->link($filename): Cannot link to tainted $filename:
%s", 
+                   SvPV_nolen(ST(1)));
+
+    sv = ST(0);
+    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
+
+    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
+        Perl_croak(aTHX_ "$upload->link($name): panic: can't find env.");
+
+    env = mg->mg_ptr;
+    bb = ((apreq_param_t *)SvIVX(obj))->bb;
+    name = SvPV_nolen(ST(1));
+
+    f = apreq_brigade_spoolfile(bb);
+    if (f == NULL) {
+        apr_off_t len;
+
+        s = apr_file_open(&f, name, APR_CREATE | APR_EXCL | APR_WRITE |
+                          APR_READ | APR_BINARY,
+                          APR_OS_DEFAULT,
+                          apreq_env_pool(env));
+        if (s == APR_SUCCESS) {
+            s = apreq_brigade_fwrite(f, &len, bb);
+            if (s == APR_SUCCESS)
+                XSRETURN_YES;
+        }
+        goto link_error;
+    }
+    s = apr_file_name_get(&fname, f);
+    if (s != APR_SUCCESS)
+        goto link_error;
+
+    if (PerlLIO_link(fname, name) >= 0)
+        XSRETURN_YES;
+    else {
+        s = apr_file_copy(fname, name,
+                          APR_OS_DEFAULT, 
+                          apreq_env_pool(env));
+        if (s == APR_SUCCESS)
+            XSRETURN_YES;
+    }
+
+ link_error:
+    APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::link", 
+                         "Apache::Upload::Error");
+    XSRETURN_UNDEF;
+}
+
+
+static XS(apreq_xs_upload_slurp)
+{
+    dXSARGS;
+    MAGIC *mg;
+    void *env;
+    char *data;
+    apr_off_t len_off;
+    apr_size_t len_size;
+    apr_bucket_brigade *bb;
+    SV *sv, *obj;
+    apr_status_t s;
+
+    if (items != 2 || !SvROK(ST(0)))
+        Perl_croak(aTHX_ "Usage: $upload->slurp($data)");
+
+    sv = ST(0);
+    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
+
+    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
+        Perl_croak(aTHX_ "$upload->slurp($data): can't find env");
+
+    env = mg->mg_ptr;
+    bb = ((apreq_param_t *)SvIVX(obj))->bb;
+
+    s = apr_brigade_length(bb, 0, &len_off);
+    if (s != APR_SUCCESS) {
+        APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::slurp", 
+                             "Apache::Upload::Error");
+        XSRETURN_UNDEF;
+    }
+
+    len_size = len_off; /* max_body setting will be low enough to prevent
+                         * overflow, but even if it wasn't the code below will
+                         * at worst truncate the slurp data (not segfault).
+                         */
+                         
+    SvUPGRADE(ST(1), SVt_PV);
+    data = SvGROW(ST(1), len_size + 1);
+    data[len_size] = 0;
+    SvCUR_set(ST(1), len_size);
+    SvPOK_only(ST(1));
+    s = apr_brigade_flatten(bb, data, &len_size);
+    if (s != APR_SUCCESS) {
+        APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::slurp", 
+                             "Apache::Upload::Error");
+        XSRETURN_UNDEF;
+    }
+    if (SvTAINTED(obj))
+        SvTAINTED_on(ST(1));
+    SvSETMAGIC(ST(1));
+    XSRETURN_IV(len_size);
+}
+
+static XS(apreq_xs_upload_size)
+{
+    dXSARGS;
+    MAGIC *mg;
+    void *env;
+    apr_bucket_brigade *bb;
+    apr_status_t s;
+    apr_off_t len;
+    SV *sv, *obj;
+
+    if (items != 1 || !SvROK(ST(0)))
+        Perl_croak(aTHX_ "Usage: $upload->size()");
+
+    sv = ST(0);
+    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
+
+    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
+        Perl_croak(aTHX_ "$upload->size(): can't find env");
+
+    env = mg->mg_ptr;
+    bb = ((apreq_param_t *)SvIVX(obj))->bb;
+
+    s = apr_brigade_length(bb, 1, &len);
+
+    if (s != APR_SUCCESS) {
+        APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::size", 
+                             "Apache::Upload::Error");
+        XSRETURN_UNDEF;
+    }
+
+    XSRETURN_IV((IV)len);
+}
+
+static XS(apreq_xs_upload_type)
+{
+    dXSARGS;
+    apreq_param_t *upload;
+    const char *ct, *sc;
+    STRLEN len;
+    SV *sv, *obj;
+
+    if (items != 1 || !SvROK(ST(0)))
+        Perl_croak(aTHX_ "Usage: $upload->type()");
+
+    sv = ST(0);
+    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
+
+    upload = (apreq_param_t *)SvIVX(obj);
+    ct = apr_table_get(upload->info, "Content-Type");
+    if (ct == NULL)
+        Perl_croak(aTHX_ "$upload->type: can't find Content-Type header");
+    
+    if ((sc = strchr(ct, ';')))
+        len = sc - ct;
+    else
+        len = strlen(ct);
+
+    sv = newSVpvn(ct, len);
+    if (SvTAINTED(obj))
+        SvTAINTED_on(sv);
+    ST(0) = sv_2mortal(sv);
+    XSRETURN(1);
+}
+
+APR_INLINE
+static SV *apreq_xs_find_bb_obj(pTHX_ SV *in)
+{
+    while (in && SvROK(in)) {
+        SV *sv = SvRV(in);
+        switch (SvTYPE(sv)) {            
+            MAGIC *mg;
+        case SVt_PVIO:
+            if (SvMAGICAL(sv) && (mg = mg_find(sv,PERL_MAGIC_tiedscalar))) {
+               in = mg->mg_obj;
+               break;
+            }
+            Perl_croak(aTHX_ "panic: cannot find tied scalar in pvio magic");
+        case SVt_PVMG:
+            if (SvOBJECT(sv) && SvIOKp(sv))
+                return sv;
+        default:
+             Perl_croak(aTHX_ "panic: unsupported SV type: %d", SvTYPE(sv));
+       }
+    }
+    return in;
+}
+
+
+static XS(apreq_xs_upload_brigade_copy)
+{
+    dXSARGS;
+    apr_bucket_brigade *bb, *bb_copy;
+    char *class;
+    SV *sv, *obj;
+
+    if (items != 2 || !SvPOK(ST(0)) || !SvROK(ST(1)))
+        Perl_croak(aTHX_ "Usage: Apache::Upload::Brigade->new($bb)");
+
+    class = SvPV_nolen(ST(0));
+    obj = apreq_xs_find_bb_obj(aTHX_ ST(1));
+    bb = (apr_bucket_brigade *)SvIVX(obj);
+    bb_copy = apr_brigade_create(bb->p,bb->bucket_alloc);
+    apreq_brigade_copy(bb_copy, bb);
+
+    sv = sv_setref_pv(newSV(0), class, bb_copy);
+    if (SvTAINTED(obj))
+        SvTAINTED_on(SvRV(sv));
+    ST(0) = sv_2mortal(sv);
+    XSRETURN(1);
+}
+
+static XS(apreq_xs_upload_brigade_read)
+{
+    dXSARGS;
+    apr_bucket_brigade *bb;
+    apr_bucket *e, *end;
+    IV want = -1, offset = 0;
+    SV *sv, *obj;
+    apr_status_t s;
+    char *buf;
+
+    switch (items) {
+    case 4:
+        offset = SvIV(ST(3));
+    case 3:
+        want = SvIV(ST(2));
+    case 2:
+        sv = ST(1);
+        SvUPGRADE(sv, SVt_PV);
+        if (SvROK(ST(0))) {
+            obj = apreq_xs_find_bb_obj(aTHX_ ST(0));
+            bb = (apr_bucket_brigade *)SvIVX(obj);
+            break;
+        }
+    default:
+        Perl_croak(aTHX_ "Usage: $bb->READ($buf,$len,$off)");
+    }
+
+    if (want == 0) {
+        SvCUR_set(sv, offset);
+        XSRETURN_IV(0);
+    }
+
+    if (APR_BRIGADE_EMPTY(bb)) {
+        SvCUR_set(sv, offset);
+        XSRETURN_UNDEF;
+    }
+
+    if (want == -1) {
+        const char *data;
+        apr_size_t dlen;
+        e = APR_BRIGADE_FIRST(bb);
+        s = apr_bucket_read(e, &data, &dlen, APR_BLOCK_READ);
+        if (s != APR_SUCCESS)
+            apreq_xs_croak(aTHX_ newHV(), s, 
+                           "Apache::Upload::Brigade::READ", 
+                           "APR::Error");
+        want = dlen;
+        end = APR_BUCKET_NEXT(e);
+    }
+    else {
+        switch (s = apr_brigade_partition(bb, (apr_off_t)want, &end)) {
+            apr_off_t len;
+
+        case APR_INCOMPLETE:
+            s = apr_brigade_length(bb, 1, &len);
+            if (s != APR_SUCCESS)
+                apreq_xs_croak(aTHX_ newHV(), s, 
+                               "Apache::Upload::Brigade::READ", 
+                               "APR::Error");
+            want = len;
+
+        case APR_SUCCESS:
+            break;
+
+        default:
+            apreq_xs_croak(aTHX_ newHV(), s, 
+                           "Apache::Upload::Brigade::READ",
+                           "APR::Error");
+        }
+    }
+
+    SvGROW(sv, want + offset + 1);
+    buf = SvPVX(sv) + offset;
+    SvCUR_set(sv, want + offset);
+    if (SvTAINTED(obj))
+        SvTAINTED_on(sv);
+
+    while ((e = APR_BRIGADE_FIRST(bb)) != end) {
+        const char *data;
+        apr_size_t dlen;
+        s = apr_bucket_read(e, &data, &dlen, APR_BLOCK_READ);
+        if (s != APR_SUCCESS)
+            apreq_xs_croak(aTHX_ newHV(), s, 
+                           "Apache::Upload::Brigade::READ", "APR::Error");
+        memcpy(buf, data, dlen);
+        buf += dlen;
+        apr_bucket_delete(e);
+    }
+
+    *buf = 0;
+    SvPOK_only(sv);
+    SvSETMAGIC(sv);
+    XSRETURN_IV(want);
+}
+
+static XS(apreq_xs_upload_brigade_readline)
+{
+    dXSARGS;
+    apr_bucket_brigade *bb;
+    apr_bucket *e;
+    SV *sv, *obj;
+    apr_status_t s;
+    unsigned tainted;
+
+    if (items != 1 || !SvROK(ST(0)))
+        Perl_croak(aTHX_ "Usage: $bb->READLINE");
+
+    obj = apreq_xs_find_bb_obj(aTHX_ ST(0));
+    bb = (apr_bucket_brigade *)SvIVX(obj);
+
+    if (APR_BRIGADE_EMPTY(bb))
+        XSRETURN(0);
+
+    tainted = SvTAINTED(obj);
+
+    XSprePUSH;
+
+    sv = sv_2mortal(newSVpvn("",0));
+    if (tainted)
+        SvTAINTED_on(sv);
+        
+    XPUSHs(sv);
+
+    while (!APR_BRIGADE_EMPTY(bb)) {
+        const char *data;
+        apr_size_t dlen;
+        const char *eol;
+
+        e = APR_BRIGADE_FIRST(bb);
+        s = apr_bucket_read(e, &data, &dlen, APR_BLOCK_READ);
+        if (s != APR_SUCCESS)
+            apreq_xs_croak(aTHX_ newHV(), s, 
+                           "Apache::Upload::Brigade::READLINE",
+                           "APR::Error");
+
+        eol = memchr(data, '\012', dlen); /* look for LF (linefeed) */
+
+        if (eol != NULL) {
+            if (eol < data + dlen - 1) {
+                dlen = eol - data + 1;
+                apr_bucket_split(e, dlen);
+            }
+
+            sv_catpvn(sv, data, dlen);
+            apr_bucket_delete(e);
+
+            if (GIMME_V != G_ARRAY || APR_BRIGADE_EMPTY(bb))
+                break;
+
+            sv = sv_2mortal(newSVpvn("",0));
+            if (tainted)
+                SvTAINTED_on(sv);
+            XPUSHs(sv);
+        }
+        else {
+            sv_catpvn(sv, data, dlen);
+            apr_bucket_delete(e);
+        }
+    }
+
+    PUTBACK;
+}
+
+
+static XS(apreq_xs_upload_tempname)
+{
+    dXSARGS;
+    MAGIC *mg;
+    void *env;
+    apr_bucket_brigade *bb;
+    apr_status_t s;
+    apr_file_t *file;
+    const char *path;
+    SV *sv, *obj;
+
+    if (items != 1 || !SvROK(ST(0)))
+        Perl_croak(aTHX_ "Usage: $upload->tempname()");
+
+    sv = ST(0);
+    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
+
+    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
+        Perl_croak(aTHX_ "$upload->tempname(): can't find env");
+
+    env = mg->mg_ptr;
+    bb = ((apreq_param_t *)SvIVX(obj))->bb;
+    file = apreq_brigade_spoolfile(bb);
+
+    if (file == NULL) {
+        apr_bucket *last;
+        apr_off_t len;
+        const char *tmpdir = apreq_env_temp_dir(env, NULL);
+
+        s = apreq_file_mktemp(&file, apreq_env_pool(env), tmpdir);
+
+        if (s != APR_SUCCESS)
+            goto tempname_error;
+
+        s = apreq_brigade_fwrite(file, &len, bb);
+
+        if (s != APR_SUCCESS)
+            goto tempname_error;
+
+        last = apr_bucket_file_create(file, len, 0, bb->p, bb->bucket_alloc);
+        APR_BRIGADE_INSERT_TAIL(bb, last);
+    }
+
+    s = apr_file_name_get(&path, file);
+    if (s != APR_SUCCESS)
+        goto tempname_error;
+
+    sv = newSVpvn(path, strlen(path));
+    ST(0) = sv_2mortal(sv);
+    XSRETURN(1);
+
+ tempname_error:
+    APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::tempname", 
+                         "Apache::Upload::Error");
+    XSRETURN_UNDEF;
+
+}
+#endif

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
Tue Mar  1 12:30:02 2005
@@ -296,9 +296,7 @@
     /*nada*/
 
   CODE:
-    RETVAL = newSVpvn(obj->v.data, obj->v.dlen);
-    if (apreq_param_is_tainted(obj))
-        SvTAINTED_on(RETVAL);
+    RETVAL = apreq_xs_param2sv(aTHX_ obj, NULL, NULL);
 
   OUTPUT:
     RETVAL
@@ -335,7 +333,7 @@
 
 
 IV
-tainted(obj, val=NULL)
+is_tainted(obj, val=NULL)
     APR::Request::Param obj
     SV *val
   PREINIT:
@@ -349,6 +347,26 @@
            apreq_param_taint_on(obj);
         else
            apreq_param_taint_off(obj);
+    }
+
+  OUTPUT:
+    RETVAL
+
+IV
+is_utf8(obj, val=NULL)
+    APR::Request::Param obj
+    SV *val
+  PREINIT:
+    /*nada*/
+
+  CODE:
+    RETVAL = apreq_param_is_utf8(obj);
+
+    if (items == 2) {
+        if (SvTRUE(val))
+           apreq_param_utf8_on(obj);
+        else
+           apreq_param_utf8_off(obj);
     }
 
   OUTPUT:

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h Tue Mar
 1 12:30:02 2005
@@ -145,7 +145,8 @@
         SV *rv = newSVpvn(p->v.data, p->v.dlen);
         if (apreq_param_is_tainted(p))
             SvTAINTED_on(rv);
-        /*XXX add charset fixups */
+        if (apreq_param_is_utf8(p))
+            SvUTF8_on(rv);
         return rv;
     }
 

Modified: httpd/apreq/branches/multi-env-unstable/include/apreq.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/include/apreq.h?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/include/apreq.h (original)
+++ httpd/apreq/branches/multi-env-unstable/include/apreq.h Tue Mar  1 12:30:02 2005
@@ -58,6 +58,10 @@
 #define APREQ_CHARSET_BIT           0
 #define APREQ_CHARSET_MASK        255
 
+#define APREQ_CHARSET_UNKNOWN       0
+#define APREQ_CHARSET_ASCII         1
+#define APREQ_CHARSET_UTF8          8
+
 #define APREQ_TAINT_BIT             8
 #define APREQ_TAINT_MASK            1
 

Modified: httpd/apreq/branches/multi-env-unstable/include/apreq_param.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/include/apreq_param.h?view=diff&r1=155820&r2=155821
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/include/apreq_param.h (original)
+++ httpd/apreq/branches/multi-env-unstable/include/apreq_param.h Tue Mar  1 12:30:02 2005
@@ -61,6 +61,25 @@
     APREQ_FLAGS_OFF(p->flags, APREQ_TAINT);
 }
 
+/** @return 1 if the taint flag is set, 0 otherwise. */
+static APR_INLINE
+unsigned apreq_param_is_utf8(const apreq_param_t *p) {
+    return APREQ_CHARSET_UTF8
+        & APREQ_FLAGS_GET(p->flags, APREQ_CHARSET);
+}
+
+/** Sets the tainted flag. */
+static APR_INLINE
+void apreq_param_utf8_on(apreq_param_t *p) {
+    APREQ_FLAGS_SET(p->flags, APREQ_CHARSET, APREQ_CHARSET_UTF8);
+}
+
+/** Turns off the taint flag. */
+static APR_INLINE
+void apreq_param_utf8_off(apreq_param_t *p) {
+    APREQ_FLAGS_SET(p->flags, APREQ_CHARSET, APREQ_CHARSET_UNKNOWN);
+}
+
 
 /** Upgrades args and body table values to apreq_param_t structs. */
 static APR_INLINE



Mime
View raw message