anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: trailofbits/polytracker
Issue: Command `polytracker info` is broken

For some reason (legacy?) the `polytracker info` command tries to print the `.header` member of a `TDFile`, which doesn't have such a member.

Changed files:
polytracker/taint_dag.py, polytracker/grammars.py, polytracker/__init__.py

diff --git a/polytracker/__init__.py b/polytracker/__init__.py
index 1fb8cc01..09035e57 100644
--- a/polytracker/__init__.py
+++ b/polytracker/__init__.py
@@ -21,7 +21,7 @@ for module_to_subsume in SUBMODULES_TO_SUBSUME:
 # Automatically load all modules in the `polytracker` package,
 # so all PolyTracker plugins will auto-register themselves:
 package_dir = Path(__file__).resolve().parent
-for (_, module_name, _) in iter_modules([str(package_dir)]):  # type: ignore
+for _, module_name, _ in iter_modules([str(package_dir)]):  # type: ignore
     if module_name == "__main__":
         continue
 
diff --git a/polytracker/grammars.py b/polytracker/grammars.py
index 2280b1af..c736c54e 100644
--- a/polytracker/grammars.py
+++ b/polytracker/grammars.py
@@ -180,9 +180,9 @@ class Production:
             return
         for rule in self.rules:
 
-            def make_tree() -> Tuple[
-                ParseTree[ParseTreeValue], ParseTree[ParseTreeValue]
-            ]:
+            def make_tree() -> (
+                Tuple[ParseTree[ParseTreeValue], ParseTree[ParseTreeValue]]
+            ):
                 root: ParseTree[ParseTreeValue] = ImmutableParseTree(self)
                 rtree: ParseTree[ParseTreeValue] = ImmutableParseTree(rule)
                 root.children.append(rtree)  # type: ignore
diff --git a/polytracker/taint_dag.py b/polytracker/taint_dag.py
index f4a1d0d2..4f7e424f 100644
--- a/polytracker/taint_dag.py
+++ b/polytracker/taint_dag.py
@@ -684,7 +684,6 @@ class TDInfo(Command):
     def run(self, args):
         with open(args.POLYTRACKER_TF, "rb") as f:
             tdfile = TDFile(f)
-            print(tdfile.header)
             print(f"Number of labels: {tdfile.label_count}")
 
             if args.print_fd_headers:
Repository: charcoal-se/smokedetector
Issue: Escape special characters from inputs (like post titles)

http://chat.meta.stackexchange.com/transcript/message/2225453#2225453

The ` in the post title screws things up.


Changed files:
ws.py

diff --git a/ws.py b/ws.py
index 20e8fd6a2f..98ea3ee0a5 100644
--- a/ws.py
+++ b/ws.py
@@ -51,8 +51,10 @@ def checkifspam(data):
 def handlespam(data):
   try:
     d=json.loads(json.loads(data)["data"])
-    reason=",".join(FindSpam.testpost(d["titleEncodedFancy"],d["siteBaseHostAddress"]))
-    s="[ [SmokeDetector](https://github.com/Charcoal-SE/SmokeDetector) ] %s: [%s](%s) on `%s`" % (reason,d["titleEncodedFancy"],d["url"],d["siteBaseHostAddress"])
+    title = d["titleEncodedFancy"]
+    reason=",".join(FindSpam.testpost(title,d["siteBaseHostAddress"]))
+    escapedTitle = re.sub(r"([_*\\\\`\\[\\]])", r"\\\\\\1", title)
+    s="[ [SmokeDetector](https://github.com/Charcoal-SE/SmokeDetector) ] %s: [%s](%s) on `%s`" % (reason,escapedTitle,d["url"],d["siteBaseHostAddress"])
     print parser.unescape(s).encode('ascii',errors='replace')
     room.send_message(s)
     roomm.send_message(s)
Repository: charcoal-se/smokedetector
Issue: Don’t delete false-positive chat messages in Charcoal HQ

Currently, if you feedback `f` to a message from Charcoal HQ, it is deleted. This should not happen.

Changed files:
chatcommands.py

diff --git a/chatcommands.py b/chatcommands.py
index 931ed6d528..6ceab873d4 100644
--- a/chatcommands.py
+++ b/chatcommands.py
@@ -1266,7 +1266,8 @@ def subcommand_falsepositive(ev_room, ev_user_id, wrap2, post_site_id, post_url,
         elif not quiet_action:
             return Response(command_status=True, message="Registered answer as false positive.")
     try:
-        if not msg.room == GlobalVars.charcoal_hq:
+        if int(msg.room.id) != int(GlobalVars.charcoal_hq.id):
+            print "Deleting message from room."
             msg.delete()
     except:
         pass
Repository: charcoal-se/smokedetector
Issue: Incorrect parsing of answer URL as question

Bhargav reported [this post](https://stackoverflow.com/questions/20038353/smooth-animation-when-tab-switches/48046679#48046679) in [this chat message](https://chat.stackoverflow.com/transcript/message/40629714#40629714):

```
 !!/report https://stackoverflow.com/questions/20038353/smooth-animation-when-tab-switches/48046679#48046679
```

The link was somehow parsed as a question link, resulting in this URL in [the report](https://chat.stackoverflow.com/transcript/message/40629715#40629715) ([MS](https://metasmoke.erwaysoftware.com/post/100010)):

```
https://stackoverflow.com/questions/20038353
```


Changed files:
parsing.py

diff --git a/parsing.py b/parsing.py
index babf42f045..3214596e66 100644
--- a/parsing.py
+++ b/parsing.py
@@ -51,7 +51,7 @@ def fetch_post_url_from_msg_content(content):
 def fetch_post_id_and_site_from_url(url):
     if url is None:
         return None
-    post_type_regex = r"\\/\\d+#\\d+$"
+    post_type_regex = r"\\/\\d+(&zwnj;&#8203;\\d+)?#\\d+$"
     post_type = ""
     search_regex = ""
     if regex.compile(post_type_regex).search(url):
Repository: charcoal-se/smokedetector
Issue: Reports for localized sites have wrong links to metasmoke

SmokeDetector once reported a post (ID 43945) that was posted to Japanese Stack Overflow: https://chat.meta.stackexchange.com/transcript/message/6947491#6947491

However, the link to metasmoke for that post attempted to find a post on regular (English) Stack Overflow with ID 43945. Understandably, it couldn't find it, because it was the wrong link. It provided [this link](https://m.erwaysoftware.com/posts/uid/stackoverflow/43945), where the proper link was [this](http://metasmoke.erwaysoftware.com/post/119321).

Changed files:
test/test_helpers.py, helpers.py

diff --git a/helpers.py b/helpers.py
index 814460fd88..a26d743ea2 100644
--- a/helpers.py
+++ b/helpers.py
@@ -77,11 +77,10 @@ def unshorten_link(url, request_type='HEAD', explicitly_ignore_security_warning=
     return url
 
 
-parser_regex = r'((?:meta\\.)?(?:(?:(?:math|stack)overflow|askubuntu|superuser|serverfault)|\\w+)(?:\\.meta)?)' \\
-               r'\\.(?:stackexchange\\.com|com|net)'
+parser_regex = r'((?:meta\\.)?(?:(?:(?:math|(?:\\w{2}\\.)?stack)overflow|askubuntu|superuser|serverfault)|\\w+)' \\
+               r'(?:\\.meta)?)\\.(?:stackexchange\\.com|com|net)'
 parser = regex.compile(parser_regex)
 exceptions = {
-    'meta.stackoverflow': 'meta.stackoverflow',
     'meta.superuser': 'meta.superuser',
     'meta.serverfault': 'meta.serverfault',
     'meta.askubuntu': 'meta.askubuntu',
@@ -96,7 +95,7 @@ def api_parameter_from_link(link):
     if match:
         if match[1] in exceptions.keys():
             return exceptions[match[1]]
-        elif 'meta.' in match[1]:
+        elif 'meta.' in match[1] and 'stackoverflow' not in match[1]:
             return '.'.join(match[1].split('.')[::-1])
         else:
             return match[1]
diff --git a/test/test_helpers.py b/test/test_helpers.py
index 7f4ebc8231..c98e720d2d 100644
--- a/test/test_helpers.py
+++ b/test/test_helpers.py
@@ -42,7 +42,9 @@ def test_unshorten_link(shortened, original):
     ('meta.askubuntu.com', 'meta.askubuntu'),
     ('3dprinting.meta.stackexchange.com', '3dprinting.meta'),
     ('blender.meta.stackexchange.com', 'blender.meta'),
-    ('meta.stackexchange.com', 'meta')
+    ('meta.stackexchange.com', 'meta'),
+    ('ja.stackoverflow.com', 'ja.stackoverflow'),
+    ('meta.ja.stackoverflow.com', 'meta.ja.stackoverflow')
 ])
 def test_api_parameter_from_link(link, param):
     assert helpers.api_parameter_from_link(link) == param