Changeset: 7a65c6210abc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7a65c6210abc
Added Files:
sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.sql
sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.err
sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.out
Modified Files:
monetdb5/modules/atoms/url.c
sql/test/BugTracker-2012/Tests/url_script_test.Bug-2972.stable.out
sql/test/BugTracker-2020/Tests/All
Branch: Jun2020
Log Message:
Fix for bug 6844, ie parse correctly the user field from URLs
diffs (274 lines):
diff --git a/monetdb5/modules/atoms/url.c b/monetdb5/modules/atoms/url.c
--- a/monetdb5/modules/atoms/url.c
+++ b/monetdb5/modules/atoms/url.c
@@ -648,31 +648,28 @@ URLgetRobotURL(str *retval, url *val)
return MAL_SUCCEED;
}
-
/* COMMAND "getUser": Extract the user identity from the URL
* SIGNATURE: getUser(str) : str; */
str
URLgetUser(str *retval, url *val)
{
- const char *s;
- const char *p;
- const char *u;
+ const char *s, *h, *u, *p;
if (val == NULL || *val == NULL)
throw(ILLARG, "url.getUser", "url missing");
if ((s = skip_scheme(*val)) == NULL ||
- (p = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL ||
- (s = skip_path(p, NULL, NULL)) == NULL)
- throw(ILLARG, "url.getUser", "bad url");
- if (p == s || *p != '/' || p[1] != '~') {
+ (s = skip_authority(s, &u, &p, &h, NULL)) == NULL)
+ throw(ILLARG, "url.getHost", "bad url");
+ if (u == NULL || h == NULL) {
*retval = GDKstrdup(str_nil);
} else {
size_t l;
- u = p + 2;
- for (p = u; p < s && *p != '/'; p++)
- ;
- l = p - u;
+ if (p) {
+ l = p - u - 1;
+ } else {
+ l = h - u - 1;
+ }
if ((*retval = GDKmalloc(l + 1)) != NULL) {
strcpy_len(*retval, u, l + 1);
}
diff --git a/sql/test/BugTracker-2012/Tests/url_script_test.Bug-2972.stable.out
b/sql/test/BugTracker-2012/Tests/url_script_test.Bug-2972.stable.out
--- a/sql/test/BugTracker-2012/Tests/url_script_test.Bug-2972.stable.out
+++ b/sql/test/BugTracker-2012/Tests/url_script_test.Bug-2972.stable.out
@@ -51,7 +51,7 @@ stdout of test 'url_script_test.Bug-2972
#insert into t2972
values('http://www.monetdb.org:8080/Documentation/Manuals/SQLreference/Datamanipulation');
[ 1 ]
#select getAnchor(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 0 # length
@@ -59,7 +59,7 @@ stdout of test 'url_script_test.Bug-2972
[ NULL ]
[ NULL ]
#select getBasename(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 16 # length
@@ -67,7 +67,7 @@ stdout of test 'url_script_test.Bug-2972
[ NULL ]
[ "Datamanipulation" ]
#select getContext(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 52 # length
@@ -75,7 +75,7 @@ stdout of test 'url_script_test.Bug-2972
[ NULL ]
[ "/Documentation/Manuals/SQLreference/Datamanipulation" ]
#select getDomain(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 3 # length
@@ -83,7 +83,7 @@ stdout of test 'url_script_test.Bug-2972
[ "com" ]
[ "org" ]
#select getExtension(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 3 # length
@@ -91,7 +91,7 @@ stdout of test 'url_script_test.Bug-2972
[ NULL ]
[ NULL ]
#select getFile(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 16 # length
@@ -99,7 +99,7 @@ stdout of test 'url_script_test.Bug-2972
[ NULL ]
[ "Datamanipulation" ]
#select getHost(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 15 # length
@@ -107,7 +107,7 @@ stdout of test 'url_script_test.Bug-2972
[ "www.monetdb.com" ]
[ "www.monetdb.org" ]
#select getPort(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 4 # length
@@ -115,7 +115,7 @@ stdout of test 'url_script_test.Bug-2972
[ NULL ]
[ "8080" ]
#select getQuery(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 3 # length
@@ -123,15 +123,15 @@ stdout of test 'url_script_test.Bug-2972
[ "x=2" ]
[ NULL ]
#select getUser(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
-% 2 # length
-[ "mk" ]
+% 0 # length
+[ NULL ]
[ NULL ]
[ NULL ]
#select getRobotURL(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% clob # type
% 38 # length
@@ -139,7 +139,7 @@ stdout of test 'url_script_test.Bug-2972
[ "http://www.monetdb.com/robots.txt" ]
[ "http://www.monetdb.org:8080/robots.txt" ]
#select isaURL(u) from t2972;
-% sys. # table_name
+% sys.%1 # table_name
% %1 # name
% boolean # type
% 5 # length
@@ -147,32 +147,32 @@ stdout of test 'url_script_test.Bug-2972
[ true ]
[ true ]
#select isaURL('http://www.monetdb.org');
-% . # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
% boolean # type
% 5 # length
[ true ]
#select isaURL('http://www.monetdb.org');
-% . # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
% boolean # type
% 5 # length
[ true ]
#select isaURL('htp:///www.monetdb.org');
-% . # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
% boolean # type
% 5 # length
[ true ]
#select newurl('https','www.monetdb.org',8080,'blah');
-% . # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
% url # type
% 33 # length
[ https://www.monetdb.org:8080/blah ]
#select newurl('https','localhost','boe');
-% . # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
% url # type
% 21 # length
[ https://localhost/boe ]
diff --git a/sql/test/BugTracker-2020/Tests/All
b/sql/test/BugTracker-2020/Tests/All
--- a/sql/test/BugTracker-2020/Tests/All
+++ b/sql/test/BugTracker-2020/Tests/All
@@ -7,6 +7,7 @@ NOT_WIN32&HAVE_LIBR&HAVE_LIBPY3?function
cume-dist-wrong-results.Bug-6827
window-order-by-extract.Bug-6828
ntile-wrong-results.Bug-6829
+url-getuser.Bug-6844
HAVE_PYMONETDB?global_table_propagation.Bug-6846
ilike-matches.Bug-6864
select-and.Bug-6878
diff --git a/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.sql
b/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.sql
@@ -0,0 +1,6 @@
+select sys.getUser('https://me:[email protected]/Doc');
+ -- me
+select sys.getUser('http://[email protected]/vision2011.pdf');
+ -- mk
+select sys.getUser('http://www.cwi.nl/~mk/vision2011.pdf');
+ -- NULL
diff --git a/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.err
b/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.err
@@ -0,0 +1,12 @@
+stderr of test 'url-getuser.Bug-6844` in directory 'sql/test/BugTracker-2020`
itself:
+
+
+# 18:53:36 >
+# 18:53:36 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-431784" "--port=35988"
+# 18:53:36 >
+
+
+# 18:53:36 >
+# 18:53:36 > "Done."
+# 18:53:36 >
+
diff --git a/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.out
b/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.out
@@ -0,0 +1,30 @@
+stdout of test 'url-getuser.Bug-6844` in directory 'sql/test/BugTracker-2020`
itself:
+
+
+# 18:53:36 >
+# 18:53:36 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-431784" "--port=35988"
+# 18:53:36 >
+
+#select sys.getUser('https://me:[email protected]/Doc');
+% .%2 # table_name
+% %2 # name
+% clob # type
+% 2 # length
+[ "me" ]
+#select sys.getUser('http://[email protected]/vision2011.pdf');
+% .%2 # table_name
+% %2 # name
+% clob # type
+% 2 # length
+[ "mk" ]
+#select sys.getUser('http://www.cwi.nl/~mk/vision2011.pdf');
+% .%2 # table_name
+% %2 # name
+% clob # type
+% 0 # length
+[ NULL ]
+
+# 18:53:36 >
+# 18:53:36 > "Done."
+# 18:53:36 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list