Branch: Tag:

2011-07-13

2011-07-13 16:07:11 by Henrik Grubbström (Grubba) <grubba@grubba.org>

ConfigIF: Improved robustness against multiple variable submits.

Rev: server/etc/modules/Variable.pmod/MapLocation.pike:1.7
Rev: server/etc/modules/Variable.pmod/Mapping.pike:1.10
Rev: server/etc/modules/Variable.pmod/module.pmod:1.118

1: - // $Id: module.pmod,v 1.117 2009/10/13 11:55:27 mast Exp $ + // $Id: module.pmod,v 1.118 2011/07/13 16:07:11 grubba Exp $      #include <module.h>   #include <roxen.h>
530:    //! Return all form variables preficed with path().    {    string p = path(); -  array names = glob( p+"*", indices(id->variables) ); +  array names = glob( p+"*", indices(id->real_variables) );    mapping res = ([ ]);    foreach( sort(names), string n ) -  res[ n[strlen(p).. ] ] = id->variables[ n ]; +  res[ n[strlen(p).. ] ] = id->real_variables[ n ][0];    return res;    }   
545:    }       int(0..1) set_from_form( RequestID id, void|int(0..1) force ) -  //! Set this variable from the form variable in id->Variables, +  //! Set this variable from the form variable in id->variables,    //! if any are available. The default implementation simply sets    //! the variable to the string in the form variables. @[force]    //! forces the variable to be set even if the variable already
1655:    if( sscanf( vv, ".set.%d", rn ) && (vv == ".set."+rn) )    {    if ((rn >= 0) && (rn < sizeof(l))) { -  m_delete( id->variables, path()+vv ); +  m_delete( id->real_variables, path()+vv );    l[rn] = transform_from_form( vl[vv], vl );    m_delete( vl, vv );    } else {
1668:    if( sscanf( vv, ".up.%d.x%*s", rn ) == 2 )    {    do_goto = 1; -  m_delete( id->variables, path()+vv ); +  m_delete( id->real_variables, path()+vv );    m_delete( vl, vv );    l = l[..rn-2] + l[rn..rn] + l[rn-1..rn-1] + l[rn+1..];    }    else if( sscanf( vv, ".down.%d.x%*s", rn )==2 )    {    do_goto = 1; -  m_delete( id->variables, path()+vv ); +  m_delete( id->real_variables, path()+vv );    l = l[..rn-1] + l[rn+1..rn+1] + l[rn..rn] + l[rn+2..];    }    // then the possible add.    if( vl[".new.x"] )    {    do_goto = 1; -  m_delete( id->variables, path()+".new.x" ); +  m_delete( id->real_variables, path()+".new.x" );    l += ({ transform_from_form( "",vl ) });    }   
1691:    if( sscanf( vv, ".delete.%d.x%*s", rn )==2 )    {    do_goto = 1; -  m_delete( id->variables, path()+vv ); +  m_delete( id->real_variables, path()+vv );    l = l[..rn-1] + l[rn+1..];    }