Changeset 390

Show
Ignore:
Timestamp:
03/23/07 12:33:15 (2 years ago)
Author:
laurentj
Message:

fix coredumps in jelix_scan_action_sel; added unit tests for selectors in testapp; selectors cannot contain other caracters than a-zA-Z0-9_.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/testapp.mn

    r380 r390  
    6868  utparseurls.class.php 
    6969  utselectoract.class.php 
     70  utselectormod.class.php 
    7071  utsimpletest.class.php 
    7172  utdao.class.php 
  • trunk/ext/jelix/jelix.c

    r389 r390  
    607607            char *r; 
    608608            int ld = sizeof("default_") -1; 
    609             int lr = ld + resource_length+1
    610             r= emalloc(lr); 
     609            int lr = ld + resource_length
     610            r= emalloc(lr+1); 
    611611            if (r) { 
    612612                memcpy(r, "default_", ld); 
    613613                memcpy(r+ld, resource, resource_length); 
    614614                r[lr] = 0; 
    615                 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr -1 TSRMLS_CC); 
     615                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
    616616                efree(r); 
    617617            } 
     
    623623            char *r; 
    624624            int ld = sizeof("default") -1; 
    625             int lr = ld + resource_length + 1
    626             r= emalloc(lr); 
     625            int lr = ld + resource_length
     626            r= emalloc(lr+1); 
    627627            if (r) { 
    628628                memcpy(r, "default", ld); 
    629629                memcpy(r+ld, resource, resource_length); 
    630630                r[lr] = 0; 
    631                 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr -1 TSRMLS_CC); 
     631                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
    632632                efree(r); 
    633633            } 
     
    638638            char *r; 
    639639            int ld = sizeof("index") -1; 
    640             int lr = ld + resource_length +1
    641             r= emalloc(lr); 
     640            int lr = resource_length + ld
     641            r= emalloc(lr+1); 
    642642            if (r) { 
    643643                memcpy(r, resource, resource_length); 
    644644                memcpy(r+resource_length, "index", ld); 
    645645                r[lr] = 0; 
    646                 zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr -1 TSRMLS_CC); 
     646                zend_update_property_stringl(Z_OBJCE_P(*objectArg), *objectArg, "resource", sizeof("resource") - 1,     r, lr TSRMLS_CC); 
    647647                efree(r); 
    648648            } 
  • trunk/lib/jelix/core/jSelector.class.php

    r386 r390  
    103103 
    104104    function __construct($sel){ 
    105         if(preg_match("/^(([\w\.]+)~)?([\w\.]+)$/", $sel, $m)){ 
     105#if ENABLE_PHP_JELIX 
     106        if(jelix_scan_module_sel($sel, $this)){ 
     107            if($this->module ==''){ 
     108                $this->module = jContext::get (); 
     109            } 
     110#else 
     111        if(preg_match("/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_\.]+)$/", $sel, $m)){ 
    106112            if($m[1]!='' && $m[2]!=''){ 
    107113                $this->module = $m[2]; 
     
    110116            } 
    111117            $this->resource = $m[3]; 
     118#endif 
    112119            $this->_createPath(); 
    113120            $this->_createCachePath(); 
     
    190197        global $gJCoord; 
    191198 
    192         if(preg_match("/^(?:([\w\.]+|\#)~)?([\w\.]+|\#)?(?:@([\w\.]+))?$/", $sel, $m)){ 
     199#if ENABLE_PHP_JELIX 
     200jLog::log("sel : ".$sel." (".$gJCoord->actionName.")"); 
     201        if(jelix_scan_action_sel($sel, $this, $gJCoord->actionName)){ 
     202            if($this->module == '#'){ 
     203                $this->module = $gJCoord->moduleName; 
     204            }elseif($this->module ==''){ 
     205                $this->module = jContext::get (); 
     206            } 
     207 
     208            if($this->request == '') 
     209                $this->request = $gJCoord->request->type; 
     210 
     211#else 
     212        if(preg_match("/^(?:([a-zA-Z0-9_\.]+|\#)~)?([a-zA-Z0-9_]+|\#)?(?:@([a-zA-Z0-9_]+))?$/", $sel, $m)){ 
    193213            $m=array_pad($m,4,''); 
    194214            if($m[1]!=''){ 
     
    219239            else 
    220240                $this->request = $gJCoord->request->type; 
    221  
     241#endif 
    222242            $this->_createPath(); 
    223243        }else{ 
     
    316336        $this->_compilerPath=JELIX_LIB_CORE_PATH.'jLocalesCompiler.class.php'; 
    317337 
    318         if(preg_match("/^(([\w\.]+)~)?(\w+)\.([\w\.]+)$/", $sel, $m)){ 
     338        if(preg_match("/^(([a-zA-Z0-9_\.]+)~)?([a-zA-Z0-9_]+)\.([a-zA-Z0-9_\.]+)$/", $sel, $m)){ 
    319339            if($m[1]!='' && $m[2]!=''){ 
    320340                $this->module = $m[2]; 
  • trunk/testapp/modules/unittest/classes/unittestservice.class.php

    r380 r390  
    4545      $test->run(new jHtmlRespReporter($this->_rep)); 
    4646   } 
     47   function selectorModTest(){ 
     48      $test = jClasses::create("utselectormod"); 
     49      $test->run(new jHtmlRespReporter($this->_rep)); 
     50   } 
    4751 
    4852   function daoConditionsTest(){ 
  • trunk/testapp/modules/unittest/classes/utselectoract.class.php

    r389 r390  
    121121            } 
    122122 
    123             $this->assertTrue($ok , ' test de '.$sel); 
     123            $this->assertTrue($ok , ' test de '.$sel. ' (devrait ĂȘtre '.($res === false ? 'invalide':'valide').')'); 
    124124            if($msg) 
    125125                $this->sendMessage($msg); 
  • trunk/testapp/modules/unittest/controllers/default.classic.php

    r386 r390  
    6666      return $rep; 
    6767   } 
     68   function testselectormod(){ 
     69      $rep = $this->getResponse('unittest'); 
     70      $rep->title = 'test unitaires sur les selecteurs normaux'; 
     71 
     72      $ut = jClasses::create("unittestservice"); 
     73      $ut->init($rep); 
     74      $ut->selectorModTest(); 
     75      return $rep; 
     76   } 
    6877 
    6978 
  • trunk/testapp/modules/unittest/templates/menu.tpl

    r386 r390  
    66<h3>Core</h3> 
    77<ul> 
    8     <li><a href="{jurl 'unittest~testselectoract'}">selecteurs d'action</a></li> <!--?module=unittest&amp;action=testselectoract--> 
     8    <li><a href="?module=unittest&amp;action=default_testselectormod">selecteurs normaux</a></li> <!--{jurl 'unittest~testselectormod'} --> 
     9    <li><a href="?module=unittest&amp;action=testselectoract">selecteurs d'action</a></li> <!--{jurl 'unittest~default_testselectoract'} --> 
    910    <li><a href="?module=unittest&amp;action=testlocaleprop">lecture .properties</a></li> 
    1011 
Download in other formats: Unified Diff Zip Archive