David Jeske | 7 Apr 2012 23:57
Picon
Gravatar

clearsilver bug in cgi-parse, form posting with explicit chartset...

 

I just ran into a bug in clearsilver that I'm surprised has existed for so long.

The problem occured because Firefox is specifying a character set in the content type of form posts, ala...

   application/x-www-form-urlencoded; charset=UTF-8

Clearsilver cgi_parse was expecting an exact match for "application/x-www-form-urlencoded"..

I fixed this by having clearsilver check only the prefix of content type, as you can see in my patch below. There is probably a better way to fix this, by having clearsilver properly parse the content type for it's parts according to the spec. Though perhaps this fix is enough...




root <at> w5:/home/hassan# diff -c clearsilver-0.10.5-orig/cgi/cgi.c clearsilver-0.10.5/cgi/cgi.c
*** clearsilver-0.10.5-orig/cgi/cgi.c   2007-07-11 19:38:03.000000000 -0700
--- clearsilver-0.10.5/cgi/cgi.c        2012-04-07 14:52:12.742725038 -0700
***************
*** 640,646 ****

    if (!strcmp(method, "POST"))
    {
!     if (type && !strcmp(type, "application/x-www-form-urlencoded"))
      {
        err = _parse_post_form(cgi);
        if (err != STATUS_OK) return nerr_pass (err);
--- 640,647 ----

    if (!strcmp(method, "POST"))
    {
!     const char *formType = "application/x-www-form-urlencoded";
!     if (type && !strncmp(type, formType, strlen(formType)-1 ))
      {
        err = _parse_post_form(cgi);
        if (err != STATUS_OK) return nerr_pass (err);

__._,_.___
Recent Activity:
    .

    __,_._,___
    bxxx | 23 Apr 2012 09:51
    Picon
    Favicon

    Filter at runtime

     

    Hello Brandon, hello everybody,

    I want to filter every dataset into clearsilver hdf at runtime.
    OR is it possible to (override | add hook) "var" hdf function ?

    thanks
    VB

    __._,_.___
    Recent Activity:
      .

      __,_._,___
      Brandon Long | 24 Apr 2012 06:45
      Favicon

      Re: Filter at runtime

       

      I'm not sure I understand. You want to intercept every hdf_set_value
      call to change what is set?

      There isn't a way to do this in C. In Java/Python where there's an
      object wrapper to HDF, you can sub-class the object to implement
      something like this.

      In C, you'd have to have your own set of functions to call instead,
      which would call the underlying HDF functions.

      Brandon

      On Mon, Apr 23, 2012 at 12:51 AM, bxxx <vincebouix <at> yahoo.fr> wrote:
      > Hello Brandon, hello everybody,
      >
      > I want to filter every dataset into clearsilver hdf at runtime.
      > OR is it possible to (override | add hook) "var" hdf function ?
      >
      > thanks
      > VB
      >
      >
      >
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >

      __._,_.___
      Recent Activity:
        .

        __,_._,___

        Gmane