10

On math.SE a tag called (arithmetic--topology) has been created a few days ago. (It was created on Jun 9 at 10:19 according to the list of new tags.) The two hyphens in the tag name are probably a typo an the tag name is going to be corrected eventually. But still this revealed an interesting bug.

If you display the questions having this tag, you see "0 questions tagged (arithmetic--topology)". The popup says "0 followers, 1 question". As you can check here, there is a question having this tag.

Since the tag has been there for a few days, I doubt that this is caused by caching. Could the reason be the unusual tag name containing "--"?

screenshot

7
  • Yes I'm pretty sure the reason is the "--" inside the tag name. The code is using hyphen to look for synonyms, so something probably breaks somewhere down the road. Commented Jun 14, 2017 at 11:17
  • @ShadowWizard hyphen isn't synonyms, unless there happens to be a matching synonym to that effect Commented Jun 14, 2017 at 11:26
  • @Marc well, I was right in 2 out of 3 points then.... (reason is the "--" and something broke down the road.:)) Commented Jun 14, 2017 at 11:29
  • this now works - I'm not going to opine on whether or not it is a good tag :) Commented Jun 14, 2017 at 12:15
  • Thanks @MarcGravell. I'll leave the tag in the current form for a few days so that other users who see this question can test this, but I'll get to correcting the typo later (or I'll badger the tag creator to do so) - well unless somebody does that before me.
    – Martin
    Commented Jun 14, 2017 at 12:18
  • @Martin I'm the author of the post that contains the tag and also the author of the tag (since it did not exist previous to that post). I'm commenting here just to confirm that I did not intend for a double hyphen. I tried to edit the tag but found no option to edit the tag name itself.
    – Darth Geek
    Commented Jun 23, 2017 at 8:44
  • I will just add that, in this specific case, the tag name has already been changed from two hyphens to one.
    – Martin
    Commented Jul 6, 2017 at 7:42

1 Answer 1

10

Found it!; the offending code is intended to deal with double-negatives:

query = query.Trim().Replace("--", "");

from the tag engine's perspective, a leading - on a tag means "not", so the intent is that --foo becomes foo. But this is incorrectly impacting double-negatives in the middle of tags. This shall be fixed.

I guess we just never expected anyone to create a tag with a -- in the middle! There's now a unit test for this scenario.

The new version is a positive look-behind (for the regex-aware folks):

query = Regex.Replace(query, @"(?<=^|\s+)(\-\-)+", "");
2
  • 3
    I guess we just never expected anyone to create a tag with a -- in the middle! - If it wasn't for those pesky users - software development would be so much less stressful... :) Commented Jun 14, 2017 at 11:47
  • Oh wait... I typoed - I meant so much less fun :p Commented Jun 14, 2017 at 11:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .