URLs such as http://twitter.com/#!/TED_TALKS are considered invalid by the parser. Patch against 6.x-2.9 attached.

Comments

akalata’s picture

Status: Active » Needs review

Worked for me, thanks!

Flagging as 'needs review' so a committer can look at it.

alanmackenzie’s picture

I can confirm that the patch submitted in the original post works as described.

dqd’s picture

Status: Needs review » Reviewed & tested by the community

since D7 final release has priority in the moment, I only can promise that we will review all helpful D6 patches after D7 release to find its way into next D6 release.

Thanks for all input and effort - much appreciated!

INFO: Drupal 5 issues support dropped from now on. Files stay online for any use.

dkingofpa’s picture

Status: Reviewed & tested by the community » Needs work

The provided patch would not apply using git apply -v link_hash_bang.patch and returned the message error: No changes. However, the patch did apply using patch -p0 < link_hash_bang.patch. Please re-roll the patch using git. http://drupal.org/node/707484

dqd’s picture

dkingofpa, since you already did a succesful patch, why don't you diff/patch against the release you used and provide the reroll by yourself? It would only be 2 mouseclicks from your point now ...

Anonymous’s picture

I can attest that the patch works as described.

jasonawant’s picture

marcvangend’s picture

Status: Needs work » Needs review
StatusFileSize
new736 bytes

@jwant: Since you have already closed #401138: Allow exclamation in URL I will contribute here, but in case of duplicate issues, it's common practice to close the newer issue in favor of the older. That way, the initial reporter gets the credits he deserves.

The proposed patch fixes exclamations in the anchor part, but not in the query part. Here is a patch that supports both.

jasonawant’s picture

Hi,

Thanks for the info. Close new issues in favor of the older...noted.

Thanks again, jwant.

jcfiala’s picture

You know, I'm happier when people provide patches that come with tests. :)

marcvangend’s picture

jcfiala, I understand and agree.

I just had a quick look at link.validate.test and it looks like we could easily add some URLs in function testValidateExternalLinks(). For instance, adding 'http://example.com/?exclamationmark!' and 'http://example.com/#!/username' should be enough to test if exclamation marks are allowed in the query and anchor part. However, that's not all there is to it.

My patch merely adds one character to a much longer list of special characters (like $-_.+*'(),) that are all allowed (according to http://tools.ietf.org/html/rfc1738). Most of those characters are not covered by tests at the moment. We would be fooling ourselves if we just add tests for exclamation marks in queries and anchors and consider it done.

That said, adding tests for all special characters seems beyond the scope of this issue. I suggest that we get the fix from #8 committed and open a new issue for tests for all special characters.

jcfiala’s picture

Hmm.. patch didn't work.

output was:

Checking patch link.module...
error: while searching for:

$directories = "(?:\/[a-z0-9". $LINK_ICHARS ."_\-\.~+%=&,$'#!():;*@\[\]]*)*";
// Yes, four backslashes == a single backslash.
$query = "(?:\/?\?([?a-z0-9". $LINK_ICHARS ."+_|\-\.~\/\\\\%=&,$'():;*@\[\]{} ]*))";
$anchor = "(?:#[a-z0-9". $LINK_ICHARS ."_\-\.~+%=&,$'():;*@\[\]\/\?]*)";

// The rest of the path for a standard URL.
$end = $directories .'?'. $query .'?'. $anchor .'?'.'$/i';

error: patch failed: link.module:991
error: link.module: patch does not apply

jcfiala’s picture

Status: Needs review » Needs work

Forgot to change the status.

marcvangend’s picture

I rolled my patch against the 8.x-1.x branch; against which branch did you try to apply it?

dqd’s picture

@jcfiala, that's what I thought by looking on the code of this patch ... it can't apply.

didlix’s picture

Status: Needs work » Needs review
StatusFileSize
new711 bytes

Here's a patch for 6.x-2.x-dev which has moved the code from link.module into link.inc

didlix’s picture

StatusFileSize
new1.38 KB

And here's one where I've added a hash bang url to the valid examples test file, though I have no idea how testing works in drupal/php.

ecvandenberg’s picture

In my configuration special characters in the URL are still replaced by their corresponding code.
A comma is replaced by %2c and an exclamation mark is replaced by %21. Question mark is not replaced.

Drupal 7.14
Link 7.x-1.0 and also tried Link 7.x-1.0+28-dev (2012-aug-18)

As I understand due to post #11 these characters should not be replaced, but in my case they do. Does anyone have a clue?
I know this issue is about version 6.x but it seemed better to post here.

damienmckenna’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

Thank you all for your efforts, but I'm sorry to say that the D6 version is no longer supported.