Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

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

weierophinney opened this issue Dec 31, 2019 · 1 comment
Labels
Bug Something isn't working

Comments

@weierophinney
Copy link
Member

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).


Originally posted by @tasmaniski at zendframework/zend-view#82

@weierophinney weierophinney added the Bug Something isn't working label Dec 31, 2019
@weierophinney
Copy link
Member 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


Originally posted by @tasmaniski at zendframework/zend-view#82 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant