Changeset 2502

Show
Ignore:
Timestamp:
02/22/10 18:08:48 (5 months ago)
Author:
mikey
Message:

fix problems with dots and spaces in url param names

Location:
framework/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • framework/trunk/src/main/php/net/stubbles/peer/stubURL.php

    r2425 r2502  
    5252 
    5353        if ($this->hasQuery() === true) { 
    54             parse_str($this->url['query'], $this->params); 
     54            // do not use parse_str() as this breaks param names containing 
     55            // dots or spaces 
     56            foreach (explode('&', $this->url['query']) as $param) { 
     57                list($key, $value)  = explode('=', $param); 
     58                $this->params[$key] = $value; 
     59            } 
    5560        } 
    5661    } 
  • framework/trunk/src/test/php/net/stubbles/peer/stubURLTestCase.php

    r2425 r2502  
    403403 
    404404    /** 
     405     * @test 
     406     */ 
     407    public function paramsWithDots() 
     408    { 
     409        $url = stubURL::fromString('http://example.org/?foo.bar=baz.baz'); 
     410        $this->assertTrue($url->hasQuery()); 
     411        $this->assertEquals('http://example.org/?foo.bar=baz.baz', $url->get()); 
     412        $this->assertEquals('http://example.org/?foo.bar=baz.baz', $url->get(true)); 
     413        $this->assertEquals('http://example.org/?foo.bar=baz.baz', $url->get(true, false)); 
     414        $this->assertSame($url, $url->addParam('bar.baz', 'foo.foo')); 
     415        $this->assertEquals('http://example.org/?foo.bar=baz.baz&bar.baz=foo.foo', $url->get()); 
     416        $this->assertEquals('http://example.org/?foo.bar=baz.baz&bar.baz=foo.foo', $url->get(true)); 
     417        $this->assertEquals('http://example.org/?foo.bar=baz.baz&bar.baz=foo.foo', $url->get(true, false)); 
     418    } 
     419 
     420    /** 
    405421     * assure that wrong parameters throw an exception 
    406422     *