Skip to content

Commit

Permalink
Merge pull request #1741 from NVIDIA/bot-auto-merge-branch-24.02
Browse files Browse the repository at this point in the history
[auto-merge] bot-auto-merge-branch-24.02 to branch-24.04 [skip ci] [bot]
  • Loading branch information
nvauto authored Jan 26, 2024
2 parents 6f04c8c + e966867 commit 31c0e18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/main/cpp/src/parse_uri.cu
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,10 @@ __device__ std::pair<string_view, bool> find_query_part(string_view haystack, st
auto h = haystack.data();
auto const end_h = haystack.data() + find_length;
auto n = needle.data();
bool match = false;
while (h < end_h) {
bool match = true;
for (size_type jdx = 0; match && (jdx < n_bytes); ++jdx) {
match = false; // initialize to false to prevent empty query key
for (size_type jdx = 0; (jdx == 0 || match) && (jdx < n_bytes); ++jdx) {
match = (h[jdx] == n[jdx]);
}
if (match) { match = n_bytes < haystack.size_bytes() && h[n_bytes] == '='; }
Expand All @@ -519,8 +520,8 @@ __device__ std::pair<string_view, bool> find_query_part(string_view haystack, st
h++;
}

// if h is past the end of the haystack, no match.
if (haystack.data() + haystack.size_bytes() <= h || *h != '=') { return {{}, false}; }
// if not match or no value, return nothing
if (!match || *h != '=') { return {{}, false}; }

// skip over the =
h++;
Expand Down
13 changes: 10 additions & 3 deletions src/test/java/com/nvidia/spark/rapids/jni/ParseURITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ void parseURISparkTest() {
"https://[::1]/?invalid=param&~.=!@&^",
"userinfo@www.nvidia.com/path?query=1#Ref",
"",
null};

null,
"https://www.nvidia.com/?cat=12",
"www.nvidia.com/vote.php?pid=50",
"https://www.nvidia.com/vote.php?=50",
};

String[] queries = {
"a",
Expand Down Expand Up @@ -270,7 +273,11 @@ void parseURISparkTest() {
"invalid",
"query",
"a",
"f"};
"f",
"query",
"query",
""
};

testProtocol(testData);
testHost(testData);
Expand Down

0 comments on commit 31c0e18

Please sign in to comment.