Skip to content

Commit

Permalink
updating fragment verification
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Wilson <[email protected]>
  • Loading branch information
hyperbolic2346 committed Nov 21, 2023
1 parent 688385f commit a131d00
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/main/cpp/src/parse_uri.cu
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,11 @@ uri_parts __device__ validate_uri(const char* str, int len)

// anything after the hash is part of the fragment and ignored for this part
if (hash >= 0) {
ret.fragment = {str + hash, len - hash};
if (!validate_fragment(ret.fragment)) { ret.fragment = {}; }
ret.fragment = {str + hash + 1, len - hash - 1};
if (!validate_fragment(ret.fragment)) {
ret.valid = false;
return ret;
}

len = hash;

Expand Down
15 changes: 11 additions & 4 deletions src/main/cpp/tests/parse_uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ TEST_F(ParseURIProtocolTests, SparkEdges)
"http://[fe80::7:8%eth0]",
"http://[fe80::7:8%1]",
"http://foo.bar/abc/\\\\\\http://foo.bar/abc.gif\\\\\\",
"b.oscars.org:8100/servlet/"
"www.nvidia.com:8100/servlet/"
"impc.DisplayCredits?primekey_in=2000041100:05:14115240636",
"https://j.mp/2Ru15Ss "});
"https://nvidia.com/2Ru15Ss ",
"http://www.nvidia.com/plugins//##"});

auto result = spark_rapids_jni::parse_uri_to_protocol(cudf::strings_column_view{col});

Expand Down Expand Up @@ -115,9 +116,15 @@ TEST_F(ParseURIProtocolTests, SparkEdges)
"http",
"http",
"",
"b.oscars.org",
"www.nvidia.com",
"",
""},
{1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0});
{1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0});

printf("expected:\n");
cudf::test::print(expected);
printf("result:\n");
cudf::test::print(result->view());

CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), expected);
}
Expand Down
13 changes: 8 additions & 5 deletions src/test/java/com/nvidia/spark/rapids/jni/ParseURITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void buildExpectedAndRun(String[] testData) {
@Test
void parseURIToProtocolSparkTest() {
String[] testData = {
"https://nvidia.com/https&#://nvidia.com",
/*"https://nvidia.com/https&#://nvidia.com",
"https://http://www.nvidia.com",
"filesystemmagicthing://bob.yaml",
"nvidia.com:8080",
Expand All @@ -69,15 +69,18 @@ void parseURIToProtocolSparkTest() {
"https://www.nvidia.com:8080/q",
"https://www.nvidia.com#8080",
"file://path/to/cool/file",
"http//www.nvidia.com/q",
"http//www.nvidia.com/q",*/
"http://?",
"http://#",
"http://#",/*
"http://??",
"http://??/",
"http://user:pass@host/file;param?query;p2",
"http://foo.bar/abc/\\\\\\http://foo.bar/abc.gif\\\\\\",
"b.oscars.org:8100/servlet/impc.DisplayCredits?primekey_in=2000041100:05:14115240636",
"https://j.mp/2Ru15Ss ",
"nvidia.com:8100/servlet/impc.DisplayCredits?primekey_in=2000041100:05:14115240636",
"https://nvidia.com/2Ru15Ss ",
"http://www.nvidia.com/xmlrpc//##",
"www.nvidia.com:8080/expert/sciPublication.jsp?ExpertId=1746&lenList=all",
"www.nvidia.com:8080/hrcxtf/view?docId=ead/00073.xml&query=T.%20E.%20Lawrence&query-join=and",*/
"",
null};

Expand Down

0 comments on commit a131d00

Please sign in to comment.