Development

#1112 (Unable to pass # as a parameter value to url_for correctly)

You must first sign up to be able to contribute.

Ticket #1112 (closed defect: fixed)

Opened 2 years ago

Last modified 6 months ago

Unable to pass # as a parameter value to url_for correctly

Reported by: jestermilard Assigned to: fabien
Priority: minor Milestone:
Component: helpers Version:
Keywords: routing, sfSimpleCMSPlugin, ulr_for Cc:
Qualification: Unreviewed

Description

Say I have this route:

view_tag:
url:	/tag/:tag
param: { module: tag, action: view }

What if a user tags something with "a#sign"? Calling

url_for('@view_tag?tag=a#sign');

will not produce the expected result. Since sfWebController::convertUrlStringToParameters() urlencodes the parameter I mustn't encode the parameter explicitly myself. On the other hand, if I pass the parameter without encoding it then this code from sfWebController::genUrl()

if (false !== ($pos = strpos($parameters, '#')))
{
   $fragment = substr($parameters, $pos + 1);
   $parameters = substr($parameters, 0, $pos);
}

will strip down the # as it'll think that "sign" is a fragment. This will produce an incorrect url.

Change History

01/08/07 11:44:42 changed by fabien

  • milestone set to post-1.0.

11/26/07 14:13:03 changed by Emiliano.Gabrielli

  • keywords set to routing, sfSimpleCMSPlugin, ulr_for.
  • owner set to fabien.
  • component set to helpers.
  • qualification set to Unreviewed.
  • milestone changed from post-1.0 to 1.0.9.

The same happens if one wants slashes int he parameter (as actually does the sfSimpleCMSPlugin) ..

if I have a slug such as "dir/subdir" I got it urlencoded, and the DB search of the wanted page fails !! passing the arg into the "query_string" parameter is not a solution, in fact as "slug" is a required parameter it has to be passed as a parameter in the first argument

Is the urlencoding necessary ??

(follow-up: ↓ 4 ) 11/26/07 14:41:35 changed by francois

For th sfSimpleCMS problem, you can use the bundled helper instead of regular url_for() calls.

http://trac.symfony-project.com/browser/plugins/sfSimpleCMSPlugin/lib/sfSimpleCMSTools.class.php

(in reply to: ↑ 3 ; follow-up: ↓ 5 ) 11/26/07 15:52:52 changed by Emiliano.Gabrielli

Replying to francois:

For th sfSimpleCMS problem, you can use the bundled helper instead of regular url_for() calls. http://trac.symfony-project.com/browser/plugins/sfSimpleCMSPlugin/lib/sfSimpleCMSTools.class.php

UrlForPage? uses url_for() .. I got to this problem just following the error I had, passing for UrlForPage?()...

.. Am I missing something ??

(in reply to: ↑ 4 ; follow-up: ↓ 6 ) 11/26/07 15:55:12 changed by Emiliano.Gabrielli

Replying to Emiliano.Gabrielli:

http://trac.symfony-project.com/browser/plugins/sfSimpleCMSPlugin/lib/sfSimpleCMSTools.class.php

UrlForPage? uses url_for() .. I got to this problem just following the error I had, passing for

genUrl() I mean, sorry .. I think the problem is here ... the routed url is already been encoded

(in reply to: ↑ 5 ) 11/26/07 16:08:44 changed by Emiliano.Gabrielli

Replying to Emiliano.Gabrielli:

genUrl() I mean, sorry .. I think the problem is here ... the routed url is already been encoded

My bad, sorry ... can figure out why, but reinstalling the plugin seems to solve my issue... .. I was having problem with the publish/unpublish links, but now they seems to work ... sorry again, I'll triple check next time ;(

11/29/07 14:29:40 changed by fabien

  • milestone deleted.

05/28/08 15:17:26 changed by FabianLange

  • status changed from new to closed.
  • resolution set to fixed.

as far as i can see this is fixed, isn't it?