nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: node-influx/node-influx
Pull request #401 (2019-06-14 14:11:59)

Fix  tag backslashes
Fixes single backslashes in tag names and values as reported in node-influx/node-influx#96

## Proposed Changes

  - Since only commas, equal signs, and spaces need to be escaped in tag names and values, the hardcoded `\\\\` pattern was removed from the `Escaper` constructor and moved to the `quoted` method, where it is actually needed to pass tests.
  - The tag test was extended for backslashes and more complex but supported cases (tested on InfluxDB 1.7).

## Checklist

- [x] A test has been added if appropriate
- [x] `npm test` completes successfully
- [x] Commit messages are in [semantic format](https://seesparkbox.com/foundry/semantic_commit_messages)


Patch:
diff --git a/src/grammar/escape.ts b/src/grammar/escape.ts
index 3b43ff9..5976005 100644
--- a/src/grammar/escape.ts
+++ b/src/grammar/escape.ts
@@ -38,7 +38,7 @@ class Escaper {
 
 	constructor(chars: string[], private wrap: string = '', private escaper: string = '\\') {
 		const patterns = chars.join('').replace(reEscape, '\\$&');
-		this._re = new RegExp('[' + patterns + '\\\\]', 'g');
+		this._re = new RegExp('[' + patterns + ']', 'g');
 	}
 
 	/**
@@ -103,7 +103,7 @@ export const escape = {
 	/**
    * Quoted escapes quoted values, such as database names.
    */
-	quoted: bindEsc(new Escaper(['"'], '"')),
+	quoted: bindEsc(new Escaper(['"', '\\\\'], '"')),
 
 	/**
    * StringLitEscaper escapes single quotes in string literals.


Test patch:
diff --git a/test/fixture/escapeTables.json b/test/fixture/escapeTables.json
index eb4954f..ea0c276 100644
--- a/test/fixture/escapeTables.json
+++ b/test/fixture/escapeTables.json
@@ -1,11 +1,14 @@
 {
   "tag": [
     ["ab", "ab"],
+    ["a\\b", "a\\b"],
+    ["a\\\\b", "a\\\\b"],
     ["a,", "a\\,"],
     ["a,b", "a\\,b"],
     ["a=b", "a\\=b"],
     ["a b", "a\\ b"],
-    ["a b=c", "a\\ b\\=c"]
+    ["a b=c", "a\\ b\\=c"],
+    ["'a' \\b=c\\,\\\\\"d\"", "'a'\\ \\b\\=c\\\\,\\\\\"d\""]
   ],
   "measurement": [
     ["ab", "ab"],