its not possible to create an url alias with + signs. they are removed.

entering
taxonomy/term/651+652+653+654/0

after saving, the plus signs are replace by spaces
taxonomy/term/651 652 653 654/0

CommentFileSizeAuthor
#19 foo | d8.png22.19 KBbleen
#8 path-module-1.patch760 bytesdrawk
#4 path-module.patch.txt739 bytesTakafumi

Comments

phuc77’s picture

Version: master »

This problem still exists in 4.7.4.

The problem lies within path_set_alias, which calls on urldecode on the given path and translates '+' into ' ' as it's supposed to do.
But in our case when we submit an url, we use + as a plus.. not as a space :(

One quick hack could be to replace the + sign with it's decoded equivalent right before we decode the path
inside path_set_alias.

  else if ($path && $alias) {
    // hack for urls with '+'
    $path = preg_replace("/[\+]/", '%2B', $path);
    $path = urldecode($path);

Other alternative is to submit taxonomy/term/651%2B652%2B653%2B654/0 instead of taxonomy/term/651+652+653+654/0.

Waiting for other suggestions...

dries’s picture

Project: Path » Drupal core
Version: » 5.x-dev
Component: Code » path.module

Apparently, this problem exists in Drupal 5.0 RC2 ...

Steven’s picture

I'm not sure why the urldecode() is there... I assume it is so that you can copy/paste the path from a URL. But it's a very dangerous operation, as this problem shows.

rawurldecode() should be safer

Takafumi’s picture

Status: Active » Needs review
StatusFileSize
new739 bytes

It works when urldecode() is replaced to rawurldecode().
However, I think that urldecode() is unnecessary.

drumm’s picture

Version: 5.x-dev » 6.x-dev
johnhanley’s picture

Surprisingly this problem still persists as of this writing.

catch’s picture

Status: Needs review » Needs work

This is still a valid issue (and it's caught me out before), but the patch no longer applies.

drawk’s picture

StatusFileSize
new760 bytes

Rerolled for 7.x

drawk’s picture

Status: Needs work » Needs review
voxpelli’s picture

drawk patch works for me - but it relies on #284899: Drupal url problem with clean urls - when that issue has been solved this patch can be applied.

Should this issue be postponed until then?

voxpelli’s picture

Version: 6.x-dev » 7.x-dev

Status: Needs review » Needs work

The last submitted patch failed testing.

postrational’s picture

Version: 7.x-dev » 6.13

The patch submitted above works. If you remove line 90 from node.module, which reads:
$alias = urldecode($alias);
then, you will be able to create aliases with the + sign in them. The problem is that these aliases don't work. After they are created, they show a "Page not found" error.

I wrote a cleaner way then just removing the line, use this function instead of urldecode:

<?php
function urldecode_helper($string){
	$array = explode('+', $string);
	for ($i=0; $i < count($array); $i++) { 
		$array[$i] = urldecode($array[$i]);
	}
	$string = implode('+', $array);
	return $string;
}
?>

Why do these aliases not work? Can someone point out where they fail, after they are already created?

voxpelli’s picture

Version: 6.13 » 7.x-dev

@postrational: I suggest looking at the issue I linked to in #10 - it's a problem with the clean url:s that needs to be fixed prior to this being fixable.

This should probably first be fixed in Drupal 7 and then be backported to Drupal 6 if possible.

sivaji_ganesh_jojodae’s picture

I wonder how drupal.org could use + in url (eg http://drupal.org/project/installation+profiles)

voxpelli’s picture

It seems to work to use + in aliases in the latest D7 version. Can anyone else confirm?

dave reid’s picture

Status: Needs work » Fixed

I can save URL aliases with spaces in them, which work absolutely fine when used with '+' in URLs.

voxpelli’s picture

Status: Fixed » Needs review

@Dave Reid: That wasn't the problem - the problem was that if you actually wanted the character + in your alias then it wasn't encoded into %2B correctly and even when it was there was a problem in #284899: Drupal url problem with clean urls which prevented that alias to be resolved properly.

#284899: Drupal url problem with clean urls is now solved in D/. Can you confirm that creating aliases with real + has also been resolved and now works as expected so that + are encoded into %2B and that aliases containing such %2B characters can be used and resolved properly?

Changing status until anyone confirms this issue.

bleen’s picture

Status: Needs review » Closed (fixed)
StatusFileSize
new22.19 KB

Tested in D7 & D8 ... all is well with the world

screenshot