This patch disallows the use of the # character in path aliases created by path.module.
Allowing this character in custom paths, while not explicitly disallowed by the relevant RFCs as far as I can tell, can cause ambiguity which is making it difficult to move forward on the issues #123103: Retain #anchors during path alias -> normal path saving and #325533: Allow <current>#fragment as a menu path, both of which aim to make it possible to create menu items with anchor fragments in Drupal's standard menu system. In other words, if someone enters a path of "foo#bar," are they referring to the path "foo#bar," or the "bar" anchor on the page at path "foo?" The latter is far more useful and likely, so let's disallow the former and remove the ambiguity.
The patch currently doesn't try to correct any current aliases with a # character in them. I'm not sure if that's a good idea, and if it is, how it should be done.
Comment | File | Size | Author |
---|---|---|---|
#3 | disallow-pound-2-D7.patch | 7.56 KB | Garrett Albright |
#1 | disallow-pound-D7.patch | 7.14 KB | Garrett Albright |
Comments
Comment #1
Garrett Albright CreditAttribution: Garrett Albright commentedHai de hee, hai de ho, where oh where did my patch go? I could have sworn I had attached it…
Comment #2
jpmckinney CreditAttribution: jpmckinney commentedPatch works as described.
I would change the error message to "The alias you have entered, %alias, is invalid. The alias cannot contain the # character."
Comment #3
Garrett Albright CreditAttribution: Garrett Albright commentedI AM COMMITTING A PATCH FROM DCSF DURING DRIES' KEYNOTE I AM SO HARD CORE
I didn't use exactly your terminology, but I did add the path to the error message.
Comment #4
Georg CreditAttribution: Georg commentedSeems to work.
I also created nodes with paths including # (before applying the patch). With the applied patch the nodes could still be accessed, but the next time you edit the node, you'll have to change the path to not have the # in it.
I think it's good. Just needs someone to look over the coding.
Comment #5
Garrett Albright CreditAttribution: Garrett Albright commentedGeorg, out of curiosity, why did you create paths with #? Just curious as to what "legit" reasons someone may have for doing so.
Comment #6
Georg CreditAttribution: Georg commentedAh, very good question. I wanted to try what happens, when this patch is applied. In real live I never did user # in paths and I don't think it a good idea to do so. But out of curiosity I had to try it anyway.
I normally don't have a "legit" reason to do so.
Comment #7
jcarrig CreditAttribution: jcarrig commentedGarrett,
One reason I can think of creating a path including a # is for ajax content.
I have implemented sites with ajax content loads and deep-linking thru Asual's jQuery Address library. If you could include a # in the url alias then it would be the same as the deep-linking url.
Just a thought...
Comment #8
Garrett Albright CreditAttribution: Garrett Albright commentedjcarrig, if this and #123103: Retain #anchors during path alias -> normal path saving can both make it in, then nothing will break in that regard. Either way, you weren't creating nodes with that path anyway.
Comment #9
RedTop CreditAttribution: RedTop commentedsubscribe
Comment #10
JeremyFrench CreditAttribution: JeremyFrench commentedI have a real issue where I would like to have a # in the menu path.
Even if it is slightly convoluted.
I have two content types with a node reference from container node -> child node. The container node has the full body of the child node in it and there can be many child nodes per parent.
The child nodes, can be tagged and treated as normal nodes in the system, but should only be viewed from the parent node. So when parent or child is saved it updates path to having something like Parent-nid#child-nid.
Another case would be if the preferred way to view a node was through a view.
Comment #11
normal_orphan CreditAttribution: normal_orphan commentedWhen I want to use jQuery UI Tabs (http://jqueryui.com/demos/tabs/) I have to use a relative link starting with '#'.
#bar1
#bar2
i cannot use
foo#bar1
foo#bar2
I can if course write it all from scratch in jQuery but then I cannot utilize the UI tabs code. Just sayin.
Comment #12
dynamicdan CreditAttribution: dynamicdan commentedSurely #social should be allowed in a menu? Jump the user down the page to the footer with social links/news? I don't see anything wrong with encouraging the use of relative hash links (or in page linking).