nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: servo/rust-url
Pull request #751 (2022-01-28 17:09:46)

Forbid | in URL hosts
Ref https://github.com/whatwg/url/pull/589


Patch:
diff --git a/url/src/host.rs b/url/src/host.rs
index d0a5595..c150dd9 100644
--- a/url/src/host.rs
+++ b/url/src/host.rs
@@ -90,24 +90,21 @@ impl Host<String> {
         }
 
         let is_invalid_domain_char = |c| {
-            matches!(
-                c,
-                | '\0'..='\u{001F}'
-                    | ' '
-                    | '#'
-                    | '%'
-                    | '/'
-                    | ':'
-                    | '<'
-                    | '>'
-                    | '?'
-                    | '@'
-                    | '['
-                    | '\\'
-                    | ']'
-                    | '^'
-                    | '\u{007F}'
-            )
+            matches!(c, |'\0'..='\u{001F}'| ' '
+                | '#'
+                | '%'
+                | '/'
+                | ':'
+                | '<'
+                | '>'
+                | '?'
+                | '@'
+                | '['
+                | '\\'
+                | ']'
+                | '^'
+                | '\u{007F}'
+                | '|')
         };
 
         if domain.find(is_invalid_domain_char).is_some() {
@@ -146,6 +143,7 @@ impl Host<String> {
                     | '\\'
                     | ']'
                     | '^'
+                    | '|'
             )
         };
 


Test patch:
diff --git a/url/tests/urltestdata.json b/url/tests/urltestdata.json
index 2909327..c1f424d 100644
--- a/url/tests/urltestdata.json
+++ b/url/tests/urltestdata.json
@@ -4707,6 +4707,11 @@
     "base": "about:blank",
     "failure": true
   },
+  {
+    "input": "sc://a|b/",
+    "base": "about:blank",
+    "failure": true
+  },
   "Forbidden host codepoints: tabs and newlines are removed during preprocessing",
   {
     "input": "foo://ho\u0009st/",
@@ -4931,6 +4936,11 @@
     "base": "about:blank",
     "failure": true
   },
+  {
+    "input": "http://a|b/",
+    "base": "about:blank",
+    "failure": true
+  },
   {
     "input": "http://a\u007Fb/",
     "base": "about:blank",
@@ -5200,6 +5210,11 @@
     "base": "about:blank",
     "failure": true
   },
+  {
+    "input": "http://ho%7Cst/",
+    "base": "about:blank",
+    "failure": true
+  },
   {
     "input": "http://ho%7Fst/",
     "base": "about:blank",
@@ -5777,6 +5792,36 @@
     "base": "about:blank",
     "failure": true
   },
+  {
+    "input": "file://%43%7C",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "file://%43|",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "file://C%7C",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "file://%43%7C/",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "https://%43%7C/",
+    "base": "about:blank",
+    "failure": true
+  },
+  {
+    "input": "asdf://%43|/",
+    "base": "about:blank",
+    "failure": true
+  },
   {
     "input": "asdf://%43%7C/",
     "base": "about:blank",
Repository: servo/rust-url
Pull request #754 (2022-02-09 20:13:21)

fix: make_relative missing filename when filenames equal in both urls
```rust
let from_path = url::Url:::parse("http://127.0.0.1:8080/file.txt").unwrap();
let to_path = url::Url:::parse("http://127.0.0.1:8080/test/file.txt").unwrap();
println!("{}", from_path.make_relative(&to_path).unwrap());
```

Expected: `"test/file.txt"`
Actual: `"test"`

Not sure if this expected is correct or if the solution is right, but it passes the tests.


Patch:
diff --git a/url/src/lib.rs b/url/src/lib.rs
index 3e58008..4d8d716 100644
--- a/url/src/lib.rs
+++ b/url/src/lib.rs
@@ -470,7 +470,7 @@ impl Url {
         }
 
         // Add the filename if they are not the same
-        if base_filename != url_filename {
+        if !relative.is_empty() || base_filename != url_filename {
             // If the URIs filename is empty this means that it was a directory
             // so we'll have to append a '/'.
             //


Test patch:
diff --git a/url/tests/unit.rs b/url/tests/unit.rs
index 0fa99b6..a987792 100644
--- a/url/tests/unit.rs
+++ b/url/tests/unit.rs
@@ -1084,6 +1084,16 @@ fn test_make_relative() {
             "http://127.0.0.1:8080/test/video?baz=meh#456",
             "video?baz=meh#456",
         ),
+        (
+            "http://127.0.0.1:8080/file.txt",
+            "http://127.0.0.1:8080/test/file.txt",
+            "test/file.txt",
+        ),
+        (
+            "http://127.0.0.1:8080/not_equal.txt",
+            "http://127.0.0.1:8080/test/file.txt",
+            "test/file.txt",
+        ),
     ];
 
     for (base, uri, relative) in &tests {
Repository: servo/rust-url
Pull request #813 (2023-02-20 03:31:49)

Implement potentially strip spaces for opaque paths
This will fix https://github.com/servo/rust-url/issues/812.


Patch:
diff --git a/url/src/lib.rs b/url/src/lib.rs
index fdcb3c0..0be004e 100644
--- a/url/src/lib.rs
+++ b/url/src/lib.rs
@@ -322,6 +322,32 @@ impl Url {
         url
     }
 
+    /// https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path
+    fn strip_trailing_spaces_from_opaque_path(&mut self) {
+        if !self.cannot_be_a_base() {
+            return;
+        }
+
+        if self.fragment_start.is_some() {
+            return;
+        }
+
+        if self.query_start.is_some() {
+            return;
+        }
+
+        let trailing_space_count = self
+            .serialization
+            .chars()
+            .rev()
+            .take_while(|c| *c == ' ')
+            .count();
+
+        let start = self.serialization.len() - trailing_space_count;
+
+        self.serialization.truncate(start);
+    }
+
     /// Parse a string as an URL, with this URL as the base URL.
     ///
     /// The inverse of this is [`make_relative`].
@@ -1434,7 +1460,8 @@ impl Url {
             self.serialization.push('#');
             self.mutate(|parser| parser.parse_fragment(parser::Input::no_trim(input)))
         } else {
-            self.fragment_start = None
+            self.fragment_start = None;
+            self.strip_trailing_spaces_from_opaque_path();
         }
     }
 
@@ -1497,6 +1524,9 @@ impl Url {
                     parser::Input::trim_tab_and_newlines(input, vfn),
                 )
             });
+        } else {
+            self.query_start = None;
+            self.strip_trailing_spaces_from_opaque_path();
         }
 
         self.restore_already_parsed_fragment(fragment);


Test patch:
diff --git a/url/tests/unit.rs b/url/tests/unit.rs
index 2993430..d27016b 100644
--- a/url/tests/unit.rs
+++ b/url/tests/unit.rs
@@ -34,6 +34,17 @@ fn test_relative_empty() {
     assert_eq!(url.as_str(), "sc://%C3%B1");
 }
 
+#[test]
+fn test_strip_trailing_spaces_from_opaque_path() {
+    let mut url: Url = "data:space   ?query".parse().unwrap();
+    url.set_query(None);
+    assert_eq!(url.as_str(), "data:space");
+
+    let mut url: Url = "data:space   #hash".parse().unwrap();
+    url.set_fragment(None);
+    assert_eq!(url.as_str(), "data:space");
+}
+
 #[test]
 fn test_set_empty_host() {
     let mut base: Url = "moz://foo:bar@servo/baz".parse().unwrap();
Repository: sharkdp/fd
Pull request #568 (2020-04-15 13:47:50)

--glob: '*' does not match on path separators
When using `--glob` in combination with `--full-path`, a `*` character does not match a path separation character (`/` or `\\`) anymore. You can use `**` for that. This allows things like `fd -p -g '/some/base/path/*/*/*.txt'` which would previously match to arbitrary depths (instead  of exactly two folders below `/some/base/path`. See #404. 


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ffd4327..9722acf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,10 @@
 
 ## Changes
 
+- When using `--glob` in combination with `--full-path`, a `*` character does not match a path
+  separation character (`/` or `\\`) anymore. You can use `**` for that. This allows things like
+  `fd -p -g '/some/base/path/*/*/*.txt'` which would previously match to arbitrary depths (instead
+  of exactly two folders below `/some/base/path`. See #404.
 
 
 ## Other
diff --git a/src/main.rs b/src/main.rs
index 5872778..69653e1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,7 +18,7 @@ use std::time;
 
 use anyhow::{anyhow, Context, Result};
 use atty::Stream;
-use globset::Glob;
+use globset::GlobBuilder;
 use lscolors::LsColors;
 use regex::bytes::{RegexBuilder, RegexSetBuilder};
 
@@ -123,7 +123,7 @@ fn run() -> Result<ExitCode> {
     }
 
     let pattern_regex = if matches.is_present("glob") {
-        let glob = Glob::new(pattern)?;
+        let glob = GlobBuilder::new(pattern).literal_separator(true).build()?;
         glob.regex().to_owned()
     } else if matches.is_present("fixed-strings") {
         // Treat pattern as literal string if '--fixed-strings' is used
@@ -296,7 +296,13 @@ fn run() -> Result<ExitCode> {
             .value_of("max-results")
             .and_then(|n| usize::from_str_radix(n, 10).ok())
             .filter(|&n| n != 0)
-            .or_else(|| if matches.is_present("max-one-result") { Some(1) } else { None }),
+            .or_else(|| {
+                if matches.is_present("max-one-result") {
+                    Some(1)
+                } else {
+                    None
+                }
+            }),
     };
 
     let re = RegexBuilder::new(&pattern_regex)


Test patch:
diff --git a/tests/tests.rs b/tests/tests.rs
index 1b8a244..ce7df82 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -272,6 +272,16 @@ fn test_full_path_glob_searches() {
         one/two/c.foo
         one/two/three/d.foo",
     );
+
+    te.assert_output(
+        &["--glob", "--full-path", "**/one/*/*.foo"],
+        " one/two/c.foo",
+    );
+
+    te.assert_output(
+        &["--glob", "--full-path", "**/one/*/*/*.foo"],
+        " one/two/three/d.foo",
+    );
 }
 
 #[test]
Repository: sharkdp/fd
Pull request #579 (2020-04-26 19:02:37)

Fix --glob behavior with empty pattern
With an empty pattern, --glob results in no matches. This does not
align with the behavior of --fixed-strings or --regex. Update the
initialization code to handle globs with empty patterns.

sharkdp: Thank you very much for your contribution!

Patch:
diff --git a/src/main.rs b/src/main.rs
index 5aa4bc8..4909743 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -122,7 +122,7 @@ fn run() -> Result<ExitCode> {
         ));
     }
 
-    let pattern_regex = if matches.is_present("glob") {
+    let pattern_regex = if matches.is_present("glob") && pattern.len() > 0 {
         let glob = GlobBuilder::new(pattern).literal_separator(true).build()?;
         glob.regex().to_owned()
     } else if matches.is_present("fixed-strings") {


Test patch:
diff --git a/tests/tests.rs b/tests/tests.rs
index e1ab05c..d541304 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -52,7 +52,7 @@ fn create_file_with_size<P: AsRef<Path>>(path: P, size_in_bytes: usize) {
     f.write_all(content.as_bytes()).unwrap();
 }
 
-/// Simple tests
+/// Simple test
 #[test]
 fn test_simple() {
     let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
@@ -70,20 +70,35 @@ fn test_simple() {
         one/two/three/d.foo
         one/two/three/directory_foo",
     );
+}
+
+/// Test each pattern type with an empty pattern.
+#[test]
+fn test_empty_pattern() {
+    let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
+    let expected = "a.foo
+    e1 e2
+    one
+    one/b.foo
+    one/two
+    one/two/c.foo
+    one/two/C.Foo2
+    one/two/three
+    one/two/three/d.foo
+    one/two/three/directory_foo
+    symlink";
 
     te.assert_output(
-        &[],
-        "a.foo
-        e1 e2
-        one
-        one/b.foo
-        one/two
-        one/two/c.foo
-        one/two/C.Foo2
-        one/two/three
-        one/two/three/d.foo
-        one/two/three/directory_foo
-        symlink",
+        &["--regex"],
+        expected,
+    );
+    te.assert_output(
+        &["--fixed-strings"],
+        expected,
+    );
+    te.assert_output(
+        &["--glob"],
+        expected,
     );
 }
Repository: vitessio/vitess
Pull request #6146 (2020-05-04 18:26:44)

Use 'SelectNone' for all equality against null


Patch:
diff --git a/go/vt/vtgate/planbuilder/route_option.go b/go/vt/vtgate/planbuilder/route_option.go
index e374e03ad6..c38c163231 100644
--- a/go/vt/vtgate/planbuilder/route_option.go
+++ b/go/vt/vtgate/planbuilder/route_option.go
@@ -269,6 +269,11 @@ func (ro *routeOption) computePlan(pb *primitiveBuilder, filter sqlparser.Expr)
 func (ro *routeOption) computeEqualPlan(pb *primitiveBuilder, comparison *sqlparser.ComparisonExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, condition sqlparser.Expr) {
 	left := comparison.Left
 	right := comparison.Right
+
+	if sqlparser.IsNull(right) {
+		return engine.SelectNone, nil, nil
+	}
+
 	vindex = ro.FindVindex(pb, left)
 	if vindex == nil {
 		left, right = right, left
@@ -277,9 +282,6 @@ func (ro *routeOption) computeEqualPlan(pb *primitiveBuilder, comparison *sqlpar
 			return engine.SelectScatter, nil, nil
 		}
 	}
-	if sqlparser.IsNull(right) {
-		return engine.SelectNone, nil, nil
-	}
 	if !ro.exprIsValue(right) {
 		return engine.SelectScatter, nil, nil
 	}


Test patch:
diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
index 8bb634c68e..74a3c7fa9a 100644
--- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
@@ -16,6 +16,24 @@
   }
 }
 
+# Query that always return empty
+"select id from user where someColumn = null"
+{
+  "QueryType": "SELECT",
+  "Original": "select id from user where someColumn = null",
+  "Instructions": {
+    "OperatorType": "Route",
+    "Variant": "SelectNone",
+    "Keyspace": {
+      "Name": "user",
+      "Sharded": true
+    },
+    "FieldQuery": "select id from user where 1 != 1",
+    "Query": "select id from user where someColumn = null",
+    "Table": "user"
+  }
+}
+
 # Single table unique vindex route
 "select id from user where user.id = 5"
 {