Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

URL helper plugins can't manage "+" character #82

Open
tasmaniski opened this issue Aug 3, 2016 · 2 comments
Open

URL helper plugins can't manage "+" character #82

tasmaniski opened this issue Aug 3, 2016 · 2 comments
Assignees
Labels

Comments

@tasmaniski
Copy link

The bug is related to zendframework/zendframework#4678 and it's still present.
The problem is that url() helper doesn't translate sign + to %2B

When I try to generate URL in a view:

$data = ['id' => 102, 'slug' => 'sport+', 'category' => 'basketball']; 
echo $this->url('post', $data);

Url helper return /basketball/102/sport+.html but it should be /basketball/102/sport%2B.html
since rawurlencode() translate sign + to %2B

From my investigate, the methods that are called:

Zend\View\Helper\Url::__invoke
    Zend\Mvc\Router\Http\TreeRouteStack::assemble
        Zend\Mvc\Router\Http\Segment::assemble
            Zend\Mvc\Router\Http\Segment::buildPath
                Zend\Mvc\Router\Http\Segment::encode 

soure: encode() method translate back %2B to +

Not sure if the bug is part of zend-view or zend-mvc.
Versions I am using zend-view (2.8.1) and zend-mvc (2.7.10).

@tasmaniski
Copy link
Author

Maybe good way to bypass the bug without braking old code,
is to add new key in the $option eg. 'force_percent_encoding'

if ((isset($options['force_percent_encoding']) && $options['force_percent_encoding'])){
    $path = convert($path);
}

 return $path;

Basically, replace chars from this list

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-view; a new issue has been opened at laminas/laminas-view#19.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants