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

  • 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. – Shadow Jun 14 '17 at 11:17
  • @ShadowWizard hyphen isn't synonyms, unless there happens to be a matching synonym to that effect – Marc Gravell Jun 14 '17 at 11:26
  • @Marc well, I was right in 2 out of 3 points then.... (reason is the "--" and something broke down the road.:)) – Shadow Jun 14 '17 at 11:29
  • this now works - I'm not going to opine on whether or not it is a good tag :) – Marc Gravell Jun 14 '17 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 Jun 14 '17 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 Jun 23 '17 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 Jul 6 '17 at 7:42
9

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
    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... :) – Jon Clements Jun 14 '17 at 11:47
  • Oh wait... I typoed - I meant so much less fun :p – Jon Clements Jun 14 '17 at 11:55

You must log in to answer this question.

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