The problem is a common one. Symfony needs to URL-encode the parameters, so
that blank spaces in parameters do not make invalid URLs. For instance, it
is possible to call:

url_for('foo/bar/msg=hello, world!')

And you do need urlencoding for this to work. If you look at the way the
routing works, you will also see that it would complexify the code quite a
lot to allow users to define a per-parameter encoding option.

As for the / being turned into a %2F because of that, a common workaround is
to dedicate a special helper to build the links containing a path. Look at
what was done in sfSimpleCMSPlugin:

function link_to_with_path($text, $uri, $options = array())
{
  return str_replace('%2F', '/', link_to($text, $uri, $options));
}

Hope this helps,

françois

2008/3/10, RickB <[EMAIL PROTECTED]>:
>
>
> On Mar 5, 2:28 pm, Jacob Coby <[EMAIL PROTECTED]> wrote:
> >
> > If you're not going to fully escape URL parameters, how do you
> > represent a slug (or some other value) in a URL with a / in it?
>
>
> Ah! I understand your problem now - you're asking about a RESTful URL
> with the request parameters converted to look like a long path.
>
> E.g. /index.php?arg=my/slug would need to be converted to /arg/my/slug
> but this raises a problem due to the / character being used to delimit
> arguments and values.
>
> The original case (/index.php?arg=my/slug) does not have a problem
> with / characters in parameters - it's fully legit in URLs to do
> this.  The problem only arises because of converting the request
> parameters to look like a long URL, in which the / character takes on
> a new meaning as the element delimiter (instead of ? and &).
>
> I have some suggestions for what they're worth: either
>
> 1. escape the / as %2F
> 2. convert the / to \ for this purpose only (which would be a
> reasonable thing to do - backslashes don't have any formal meaning in
> URLs - however this is likely not to work in IE, which treats \ and /
> as equivalent in spite of the standard definition of a URL).
> 3. don't use long URLs but go back to parameter lists (eg. /index.php?
> arg=my/slug) when this is a problem.
>
> I favour 3.
> Rick
>
> >
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to