FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

Invalid URLs with encoded URL as a route parameter #322

Closed webhdx closed 6 years ago

webhdx commented 6 years ago

Looks like due to this change: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/master/Resources/js/router.js#L216

You are not longer able to generate proper route URL if route parameter is URL encoded string: route:

example_route:
    path: /lookup/{url}
    defaults:
        _controller: 'Bundle:Controller:lookup'
    requirements:
        url: .+
    options:
        expose: true

example code:

window.Routing.generate('example_route', {url: href});

it generates http://localhost/lookup/http%3A//example.com/ instead of http://localhost/lookup/http%3A%2F%2Fexample.com which leads to 404 as Symfony is not able to match the route.

stof commented 6 years ago

are you sure about your route definition ? It does not have any url placeholder

webhdx commented 6 years ago

Sorry, copy paste mistake. Fixed.

webhdx commented 6 years ago

Looks like it was an issue on my side - even though slashes are not escaped SF is properly resolving route and parameters. Sorry for the hassle.