https://stackoverflow.com/tools/ shows that a tag named n+1 was created in the last 2 days. Clicking on the link for that tag takes one to a page showing "0 Questions tagged n 1"; it treats them as two separate tags, despite the +
being encoded as %2b
in the URL.
1 Answer
It's not exactly hard-coded, but rather a switch on how we should split the path into an array of tags. They can either be split by %20
or by +
. The '+' character is tricky because there is no definitive standard for encoding spaces, and they can be encoded either as +
or as %20
. Because URL-encoding is an important part of XSS defense, it makes it tricky to know when to encode a space as %20
or as +
, and even worse, whether when looking at a +
if it was an encoded space or if it is an unencoded +
. The only way to deal with it is to try and construct general categories of use and deal with edge cases as they arise.
Update
Sorry for the delay here. I got busy on other projects and some of the bugs I grabbed got put on the back burner. Anyway, I may have spoken too soon. Generally speaking, tags with the +
character are not allowed. There are notable exceptions (c++ being an obvious one), and those are the ones we work around. This isn't one of those. In fact, I don't think this tag ever got created. There's no history for it at all. In the case that a user really must have a +
in the tag, the recommended workaround is to use 'plus' instead. So if there are questions about some technology called Hellfire+Love and that's how everyone searches for it, then the tag would need to be hellfire-plus-love
.
Also, for searching posts over tags, the rule is that if any tag in the search has a +
in it, you must use a space as a delimiter. See also: https://meta.stackexchange.com/a/47191/136973
-
2I'm sorry, but this is just wrong on so many levels. There is a "definitive standard for encoding spaces", and if you find it "tricky" to tell encoded spaces and plus signs apart, that just means there's a bug (or several) in your code (or possibly in your design). Commented Jan 18, 2014 at 15:45
-
2Ps. A possible source of confusion is that the rules are (slightly) different in the path and query parts of the URL: in the path, a literal
+
is just a plus sign, in the query it encodes a space. Fortunately, this is the only difference -- in particular,%20
always means a space, and%2B
always means a plus sign. As long as your URL-encoding code always encodes spaces and plus signs as%20
and%2B
respectively, it will work for all parts of URLs. Commented Jan 18, 2014 at 15:54
ruby+cucumber
, but it's immediately expanded to[ruby][cucumber]
when clicking on it.