diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/restricted/uriparser | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/uriparser')
42 files changed, 4718 insertions, 4785 deletions
diff --git a/contrib/restricted/uriparser/AUTHORS b/contrib/restricted/uriparser/AUTHORS index 5c59de2947..15063063a3 100644 --- a/contrib/restricted/uriparser/AUTHORS +++ b/contrib/restricted/uriparser/AUTHORS @@ -1,2 +1,2 @@ -Weijia Song <songweijia@gmail.com> -Sebastian Pipping <sebastian@pipping.org> +Weijia Song <songweijia@gmail.com> +Sebastian Pipping <sebastian@pipping.org> diff --git a/contrib/restricted/uriparser/COPYING b/contrib/restricted/uriparser/COPYING index 261c741da0..c235015869 100644 --- a/contrib/restricted/uriparser/COPYING +++ b/contrib/restricted/uriparser/COPYING @@ -1,36 +1,36 @@ -uriparser - RFC 3986 URI parsing library - -Copyright (C) 2007, Weijia Song <songweijia@gmail.com> -Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - 2. Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. +uriparser - RFC 3986 URI parsing library + +Copyright (C) 2007, Weijia Song <songweijia@gmail.com> +Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/restricted/uriparser/ChangeLog b/contrib/restricted/uriparser/ChangeLog index cf1a837663..ad23c4434c 100644 --- a/contrib/restricted/uriparser/ChangeLog +++ b/contrib/restricted/uriparser/ChangeLog @@ -1,7 +1,7 @@ -NOTE: uriparser is looking for help with a few things: - https://github.com/uriparser/uriparser/labels/help%20wanted - If you can help, please get in touch. Thanks! - +NOTE: uriparser is looking for help with a few things: + https://github.com/uriparser/uriparser/labels/help%20wanted + If you can help, please get in touch. Thanks! + 2022-01-06 -- 0.9.6 >>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @@ -83,495 +83,495 @@ NOTE: uriparser is looking for help with a few things: Thanks to Jørgen Ibsen for the patch! * Soname: 1:28:0 — see https://verbump.de/ for what these numbers do -2020-05-31 -- 0.9.4 - - * Fixed: testrunner: No longer crashes when compiled with NDEBUG (GitHub #67) - * Fixed: CMake: Support GTest 1.8.0 (GitHub #68) - Thanks to Ryan Schmidt for the related report! - * Fixed: CMake: Use variable GTEST_INCLUDE_DIRS (with plural "S") rather than - GTEST_INCLUDE_DIR (GitHub #79, #81) - Thanks to Wouter Beek for the related report! - * Improved: CMake: Send config summary to stdout, not stderr (GitHub #72) - Thanks to Scott Donelan for the patch! - * Improved: Make -DURIPARSER_BUILD_TESTS=OFF unlock compilation without - a C++ compiler; thanks to Fabrice Fontaine for the patch! (GitHub #69) - * Added: Functions to make UriUri[AW] instances independent of the original - URI string (GitHub #77 and #78) - New functions: - uriMakeOwner[AW] - uriMakeOwnerMm[AW] - * Added: CMake option URIPARSER_ENABLE_INSTALL to toggle installation of - files, defaults to "ON" (GitHub #74, #75) - Thanks to Scott Donelan for the patch! +2020-05-31 -- 0.9.4 + + * Fixed: testrunner: No longer crashes when compiled with NDEBUG (GitHub #67) + * Fixed: CMake: Support GTest 1.8.0 (GitHub #68) + Thanks to Ryan Schmidt for the related report! + * Fixed: CMake: Use variable GTEST_INCLUDE_DIRS (with plural "S") rather than + GTEST_INCLUDE_DIR (GitHub #79, #81) + Thanks to Wouter Beek for the related report! + * Improved: CMake: Send config summary to stdout, not stderr (GitHub #72) + Thanks to Scott Donelan for the patch! + * Improved: Make -DURIPARSER_BUILD_TESTS=OFF unlock compilation without + a C++ compiler; thanks to Fabrice Fontaine for the patch! (GitHub #69) + * Added: Functions to make UriUri[AW] instances independent of the original + URI string (GitHub #77 and #78) + New functions: + uriMakeOwner[AW] + uriMakeOwnerMm[AW] + * Added: CMake option URIPARSER_ENABLE_INSTALL to toggle installation of + files, defaults to "ON" (GitHub #74, #75) + Thanks to Scott Donelan for the patch! * Soname: 1:27:0 - -2019-04-28 -- 0.9.3 - - * Fixed: pkg-config: Fix version line in liburiparser.pc (GitHub #65) - * Changed: MinGW: Add library version suffix to DLL name - Thanks to Sandro Mani for the patch! (GitHub #63, #64) - * Soname: 1:26:0 - -2019-04-22 -- 0.9.2 - - * Fixed: Add missing extern "C" wrapper to UriIp4.h for use from C++ - * Fixed: Linking error for symbol defaultMemoryManager from mixing C and C++ - Thanks to Jørgen Ibsen for the report! (GitHub #52) - * Fixed: Link errors on Haiku regarding function inet_ntop (GitHub #45) - Thanks to Schrijvers Luc for the patch! - * Fixed: Mark API functions with __declspec(dllexport) and - __declspec(dllimport) in *.h files for Visual Studio (GitHub #60) - * Improved: Use -fvisibility=hidden by default with supporting compilers, - e.g. GCC and Clang (GitHub #60) - * Changed: Migrated from GNU Autotools to CMake (GitHub #17, #47, #56, #59) - Thanks for their support with the CMake migration to: - - David Demelier - - Jørgen Ibsen - - KangLin - - Kouhei Sutou - - myd7349 - - Richard Hodges - - Zachary Lund - * Removed: All Windows-related build systems other than CMake - * Soname: 1:25:0 - -2019-01-02 -- 0.9.1 - ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: [CVE-2018-20721] - Out-of-bounds read in uriParse*Ex* for incomplete URIs with IPv6 - addresses with embedded IPv4 address, e.g. "//[::44.1"; - mitigated if passed parameter <afterLast> points to readable memory - containing a '\0' byte. - Commit cef25028de5ff872c2e1f0a6c562eb3ea9ecbce4 - Thanks to Joergen Ibsen for the report! ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: When parsing a malformed URI with an IPvFuture address - (e.g. "http://[vA.123456" missing "]"), errorPos would point to the first - character after "v" than the actual position of the error (here: the end - of the string) - * Fixed: uriToStringCharsRequired* reported 1 more byte than actually needed - for IPv4 address URIs (GitHub #41); Thanks to @gyh007 for the patch! - * Fixed: Compilation with MinGW - Thanks to Sandro Mani for the patch! - * Fixed: Drop use of asprintf from the test suite for MinGW (GitHub #40) - * Improved: For parse errors, waterproof errorPos <= afterLast - * Soname: 1:24:0 - -2018-10-27 -- 0.9.0 - ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: [CVE-2018-19198] - Out-of-bounds write in uriComposeQuery* and uriComposeQueryEx* - Commit 864f5d4c127def386dd5cc926ad96934b297f04e - Thanks to Google Autofuzz team for the report! - * Fixed: [CVE-2018-19199] - Detect integer overflow in uriComposeQuery* and uriComposeQueryEx* - Commit f76275d4a91b28d687250525d3a0c5509bbd666f - Thanks to Google Autofuzz team for the report! - * Fixed: [CVE-2018-19200] - Protect uriResetUri* against acting on NULL input - Commit f58c25069cf4a986fe17a80c5b38687e31feb539 ->>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - * Fixed: Be fully compliant to C89 (Gitub #28) and C++98 in test code - * Fixed: Fix off-by-one in uriComposeQueryCharsRequired* and ...Ex* - Reported space requirements were 1 byte bigger than necessary - * Changed: Marked as deprecated: - Deprecated functions: - uriNormalizeSyntaxMaskRequired[AW] - uriParseUri[AW] - uriParseUriEx[AW] - * Added: Add convenience functions to ease user code to parse a single URI - New functions: - uriParseSingleUri[AW] - uriParseSingleUriEx[AW] - uriParseSingleUriExMm[AW] - * Added: Support for custom memory managers (GitHub #26, #35), see Doxygen - New functions (as extension of existing ones): - uriAddBaseUriExMm[AW] - uriComposeQueryMallocExMm[AW] - uriDissectQueryMallocExMm[AW] - uriFreeQueryListMm[AW] - uriFreeUriMembersMm[AW] - uriNormalizeSyntaxExMm[AW] - uriParseSingleUriExMm[AW] - uriRemoveBaseUriMm[AW] - New functions (for convenience): - uriCompleteMemoryManager - uriEmulateCalloc - uriEmulateReallocarray - uriTestMemoryManager - New error codes: - URI_ERROR_MEMORY_MANAGER_FAULTY - URI_ERROR_MEMORY_MANAGER_INCOMPLETE - New types: - UriFuncCalloc - UriFuncFree - UriFuncMalloc - UriFuncRealloc - UriFuncReallocarray - UriMemoryManager - * Added: Add non-void versions of uriNormalizeSyntaxMaskRequired* - New functions: - uriNormalizeSyntaxMaskRequiredEx[AW] - * Changed: Migrate test suite from CppTest to GoogleTest 1.8.1 - * Improved: Make test suite free of memory leaks (GitHub #31) - Thanks to AddressSanitizer! - * Removed: Support for pointless define URI_SIZEDOWN (GitHub #29) - Related configure option --enable-sizedown has also been removed. - * Soname: 1:23:0 - -2018-08-18 -- 0.8.6 - - * Fixed: Bad/NULL .hostText.afterLast when parsing certain rather pathologic - but well-formed URIs with empty host (e.g. "//:%aa@") (GitHub #15) - Thanks to Kurt Schwehr for the report! - * Fixed: Fix uriRemoveBaseUri for case where scheme, host name, - IPvFuture address or path segments of the source address were - string prefixes of the related counterpart in the base URI. - Thanks to Yang Yu for the patch! (GitHub #19, #20) - * Fixed: Make UriStringToUnixFilename and UriStringToWindowsFilename - support minimal representation a la RFC 8089, e.g. file:/bin/bash - (compare to file:///bin/bash with three slashes) (GitHub #12, #14) - Thanks to Zane van Iperen for the report! - * Fixed: Documentation typos (GitHub #10, #11) - Thanks to Graham Percival! - * Improved: Made API docs of uriRemoveBaseUri more clear - (related to GitHub #19) - * Soname: 1:22:0 - -2018-02-07 -- 0.8.5 - - * Changed: The uriparser project has moved from SourceForge to GitHub: - Code + issue tracker: https://github.com/uriparser/uriparser - New website: https://uriparser.github.io/ - Please update any links of yours, accordingly. Thank you! - * Fixed: Memleak in out-of-memory clean-up code - of URI normalization, related to SF.net bug #28. - Thanks to Chris Hills for the report! - * Fixed: Fix compilation of uriparse(1) on FreeBSD - Thanks to Ed Schouten for the patch! - * Fixed: Fix C90 compilation errors - Thanks to Joel Cunningham for the patches! - * Fixed: Space requirements documented for uriWindowsFilenameToUriStringA - given URI "file://server1/file1.txt" (SF.net bug #31) - Thanks to threedyd for the report! - * Fixed: Compiler warnings - Thanks to Joel Cunningham for the patches! - * Fixed: Stop exporting internal function RemoveBaseUriImpl - Thanks to Joel Cunningham for the report! - * Fixed: API documentation front page no longer empty with Doxygen 1.8.13 - * Fixed: "make -C doc install" fixed for lack of .map files - * Improved: Communicate that absolutePath is always URI_FALSE for URIs - with a host in uriparse CLI tool output and Uri.h header - (GitHub #2, SF.net #30) - * Soname: 1:21:0 - -2015-10-12 -- 0.8.4 - - * Fixed: Stack overflow on parsing malformed IPv6 addresses with - more than eigtht quads. Thanks to Alexander Klink for the report! - * Soname: 1:20:0 - -2015-10-04 -- 0.8.3 - - * Fixed: uriCompareRange reported NULL pointer and range of - length zero as equal, by mistake. - Thanks to Robert Kausch and his Coverity report. - * Fixed: Use-after-free in out-of-memory code of uriMakeOwner. - Thanks to Chris Hills and his Klocwork-based report (SF.net bug #28) - * Soname: 1:19:0 - -2015-04-27 -- 0.8.2 - - * Fixed: Broken conversion from/to Windows network shares (SF.net bug #21) - Thanks to Adam Gross and Dmitry Repkin! - * Fixed: Limit uriCompareRange return values to -1/0/1 (SF.net bug #24) - As a side effect, this fixes the test suite for AArch64. - Thanks to Marcin Juszkiewicz for the patch! - * Fixed: MinGW Makefile: - LIB_DIR fixed from ../../lib leftover to ../../src (SF.net bug #27) - Thanks to Dmytro Zagashev for the report! - * Fixed: Add missing NULL checks to UriStringToFilename (SF.net bug #25) - Thanks to Jerome Custodio for the report! - * Changed: Leave inlining decisions to GCC - * Soname: 1:18:0 - -2014-10-20 -- 0.8.1 - - * Fixed: Sync URI_VER_* preprocessor defines (were at 0.7.6, SF.net bug #23) - * Fixed: Bug in internal function that may flip uriEqualsUri results around - * Added: Function uriAddBaseUriEx allowing to resolve URIs with - a scheme identical to that of the base URI to resolve against - as if the URI to resolve had no scheme specified, when flag - URI_RESOLVE_IDENTICAL_SCHEME_COMPAT is specified - (SF.net feature request #4) - * Soname: 1:17:0 - -2014-07-12 -- 0.8.0.1 - - * Fixed: ISO C90 warnings (SF.net bug #20) - * Changed: No longer ship RFC documents (to make things easier for Debian) - * Soname: 1:16:0 - -2013-12-20 -- 0.8.0 - - * Fixed: Resolution of relative URI "/" broken - Thanks to Mo McRoberts for the patch! - * Fixed: uriAddBaseUri produced uriUri objects with both host - and the absolutePath flag set (while the absolutePath flag - should only be true for URI objects without a host) when - resolving absolute URIs like "/" or "/foo/bar". - Now the absolutePath flag is set to URI_FALSE and an empty - segment is added as necessary - * Fixed: .errorCode could end up unset, previously - Thanks to Radu Hociung for the patch! (SF.net bug #16) - * Fixed: Resolve use of non-POSIX "sed -r" used when building - documentation (SF.net bug #18) - Thanks to Ryan Schmidt for reporting! - * Fixed: Build DLL with -no-undefined on Windows - Thanks to Michel Zou for the patch! (SF.net bug #19) - * Added: Command line tool "uriparse" - Thanks to Radu Hociung for coding! (SF.net feature request #3) - * Soname: 1:15:0 - -2013-08-24 -- 0.7.9 - - * Fixed: Error position ended up as NULL for some syntax errors. - Thanks to Daniel Solano Gómez for the patch! (SF.net bug #14) - * Soname: 1:14:0 - -2013-05-13 -- 0.7.8 - - * Fixed: Fix dissection of query string "q=hello&x=&y=" (SF.net bug #12) - Thanks to Marc Novakowski for reporting! - * Soname: 1:13:0 - -2012-04-05 -- 0.7.7 - - * Fixed: Fix rejection of some valid characters for userinfo - section, e.g. "http://%2Fuser:%2F21@host/" (SF.net bug #11) - * Fixed: Fix rejection of valid double colon in userinfo - section, e.g. "http://::@host/" - * Soname: 1:12:0 - -2012-01-20 -- 0.7.6 - - * Fixed: Qt Compressed Help file was not installed - * Fixed: Shadow/VPATH build doc generation - * Fixed: Compile error from Doxygen when configuring with - neither --enable-doc nor --disable-doc - * Fixed: Code documentation errors - Thanks to Valentin Haenel for the patch! - * Fixed: Fix include path in pkg-config, i.e. remove - "/uriparser" suffix as uriparser's headers are meant to - be included by statements like #include <uriparser/....> . - Thanks to Philip de Nier for reporting! - * Fixed: Compilation in context of Eclipse + Cygwin + wchar_t - (SF.net bug #10) - Thanks to Gary Mazzaferro for reporting! - * Fixed: Selection of supported character widths at build - time: <char *> or <wchar_t *> or both - * Added: configure parameters to disable either character - widths: --disable-char, --disable-wchar_t - * Soname: 1:11:0 - -2009-03-04 -- 0.7.5 - - * Added: pkg-config file - * Fixed: File Doxyfile.in was missing from release archives - Thanks to Rakesh Pandit for reporting! - * Fixed: Doc generation troubles - * Changed: No longer shipping bundled libcpptest - * Changed: New dependencies: - - libcpptest 1.1.0 or later - - pkg-config - The libcpptest dependency can be disabled through - configuring with --disable-test, which excludes the - test suite from compilation. - * Soname: 1:10:0 - -2008-12-23 -- 0.7.4 - - * Fixed: Null pointer de-referencing when dissecting query - strings starting with "&" right after "?" (SF.net bug #7). - Thanks to Harvey Vrsalovic for reporting! - * Fixed: Memory leak in uriFreeQueryList function (SF.net bug #6) - Thanks to Daniel Chapiesky for reporting! - * Fixed: Memory leak in uriNormalizeSyntax(Ex) functions (SF.net bug #6) - Thanks to Daniel Chapiesky for reporting! - * Improved: Nested configure hacks resolved - * Soname: 1:9:0 - -2008-11-08 -- 0.7.3 - - * Fixed: Missing NULL check in parsing routines - Thanks to Sezai Tekin for reporting! - * Fixed: uriparser now builds on Cygwin - * Fixed: Now shipping gnulib's config.guess from HEAD - which is suitable for Haiku (SF.net bug #5) - * Changed: swprintf requirement resolved - * Changed: Build system changes: - - configure option --enable-doc added - - configure.in renamed to configure.ac - - some Autotools files moved to build-aux directory - * Added: Qt Assistant documentation output: - - Qt Compressed Help (.qch) at <doc/uriparser-doc-*.qch> - - Qt Help Project (.qhp) at <doc/html/index.qhp> - Generation requires Doxygen 1.5.7.1-20081103 or later. - * Soname: 1:8:0 - -2008-09-01 -- 0.7.2 - - * Fixed: Bad cleanup logic in functions - - uriAddBaseUri(..) - - uriRemoveBaseUri(..) - Previously you needed to call uriFreeUriMembers on return code - URI_ERROR_MALLOC and only then. So that's why these functions now - take cleanup off your shoulders. An extra call to uriFreeUriMembers - from your side is still needed in case of success. - * Soname: 1:7:0 - -2008-04-27 -- 0.7.1 - - * Fixed: Bogus syntax error when parsing URIs with port-like - passwords, e.g. "http://user:21@host/" (SF.net bug #1) - Thanks to Friedrich Delgado Friedrichs for reporting! - * Fixed: Parser did not handle trailing slashes correctly in some cases, - which also made the structures produced from parsing "http://e.com/" - and "http://e.com" indistinguishable. (SF.net bug #2) - Thanks to Edward Z. Yang for reporting! - -2008-04-04 -- 0.7.0 - - * Added: Dissection and composition of query strings - * Added: Documentation improvements - (in|out|inout indicators, addition of \since and \see) - * Changed: Code::Blocks project files updated from file format - version 1.4 to 1.6, which is produced by Code::Blocks 8.02 - * Added: Code::Blocks workspace file - * Soname: 1:5:0 - -2008-02-25 -- 0.6.4 - - * Added: Syntax-based normalization can now handle relative URIs, - e.g. "../../a/b/.././c" is normalized to "../../a/c" - * Fixed: Normalization code could free foreign memory - * Fixed: Normalization processed the path segment even when asked not to - * Added: MinGW Makefile and related readme - Thanks to Michael Anthony Puls II! - * Fixed: Documentation bug not requiring enough memory for the output - buffer when converting a relative file URI back to a filename - * Soname: 1:4:0 - -2008-02-11 -- 0.6.3 - - * Fixed: Two major crash bugs in normalization code - Thanks to Adrian Manrique for the patch! - * Added: Brief usage tutorial - * Soname: 1:3:0 - -2008-02-08 -- 0.6.2 - - * Fixed: Freeing a normalized URI like "http://test?" - caused a crash. Thanks to Adrian Manrique for reporting! - * Fixed: Filename <--> URI string conversion helpers can - now handle relative URIs and filenames - * Soname: 1:2:0 - -2007-12-23 -- 0.6.1 - - * Fixed: Percent-encodings in hostnames were not repaired during normalization. - Thanks to Adrian Manrique for reporting! - * Fixed: Percent-encodings were fixed after dot removal not before during - normalization. - Thanks to Adrian Manrique for reporting! - * Fixed: Include path order bug - Thanks to Ed Schouten for reporting this! - * Fixed: Shadow builds now possible - Thanks to Adeodato Simó for the patch! - * Added: Version guards for Autoconf/Automake - Thanks to Martin Michlmayr for reporting! - * Soname: 1:1:0 - -2007-09-17 -- 0.6.0 - - * Fixed: Proper soname updates from now on, starting at 1:0:0 - * Removed: Visual Studio 2003 project files - -2007-09-13 -- 0.5.2 - - * Added: RemoveBaseUri function to create URI references - * Added: Unix/Windows filename <--> URI string conversion helpers - * Added: EscapeEx function to escape text blocks without zero termination - * Fixed: Bug in ToString for URIs with scheme, path, but no host (e.g. "f:/.//g") - * Fixed: AddBase now resolves ".//g" with base "f:/a" to "f:/.//g" instead of - "f://g" which would result in "g" becoming the authority part when parsing - a recomposition (ToString) of that URI structure. This is a whole in RFC 3986, - see http://lists.w3.org/Archives/Public/uri/2007Aug/0003.html for details. - -2007-08-09 -- 0.5.1 - - * Fixed: Empty host bug (URIs like "///g") - * Fixed: Relative URIs are no longer touched by normalization - * Fixed: MergePath failed for empty paths - * Fixed: Bug with "." segments in AddBase - All of the above revealed by test cases from 4Suite (http://4suite.org/) - -2007-07-28 -- 0.5.0 - - * Added: Syntax-based normalization - * Added: Percent-encoding function Escape - * Improved: Malloc/NULL checks added - * Added: New function UnescapeInPlaceEx can also decode '+' to ' ' - and convert line breaks - * Added: Exact space computation for ToString, see ToStringCharsRequired - * Added: --enable-sizedown for saving space and slower code - * Fixed: Two internal functions were exposed in the API by mistake: - uriPushToStack and uriStackToOctet - * Added: Visual Studio 2005 project files - * Removed: Legacy code (removal was announced for 0.5.0) - -2007-07-06 -- 0.4.1 - - * Fixed: ToString did not work for IPv4 and IPv6 hosts - -2007-07-03 -- 0.4.0 - - * Added: References resolution (think relative to absolute) - * Added: Naive URI equality check - * Added: URIs can now be converted back to strings - * Fixed: The first path segment of a relative URI was eaten - (functions ParseSegmentNz and ParseMustBeSegmentNzNc) - * Fixed: uri->scheme.first was not reset in some cases - (function ParseMustBeSegmentNzNc) - * Improved: Test suite now built on "make check", not before - * Fixed: Test suite always returned 0 (success) - -2007-04-23 -- 0.3.4 - - * Added: Shared library support (moved to libtool) - -2007-04-03 -- 0.3.3 - - * Fixed: Now unix EOLs constantly - * Fixed: Added forgotten files to release package - -2007-03-31 -- 0.3.2 - - * Fixed: Now compiles on FreeBSD - -2007-03-28 -- 0.3.1 - - * Fixed: Now compiles on Mac OS X - -2007-03-26 -- 0.3.0 - - * Added: New API, old marked deprecated + +2019-04-28 -- 0.9.3 + + * Fixed: pkg-config: Fix version line in liburiparser.pc (GitHub #65) + * Changed: MinGW: Add library version suffix to DLL name + Thanks to Sandro Mani for the patch! (GitHub #63, #64) + * Soname: 1:26:0 + +2019-04-22 -- 0.9.2 + + * Fixed: Add missing extern "C" wrapper to UriIp4.h for use from C++ + * Fixed: Linking error for symbol defaultMemoryManager from mixing C and C++ + Thanks to Jørgen Ibsen for the report! (GitHub #52) + * Fixed: Link errors on Haiku regarding function inet_ntop (GitHub #45) + Thanks to Schrijvers Luc for the patch! + * Fixed: Mark API functions with __declspec(dllexport) and + __declspec(dllimport) in *.h files for Visual Studio (GitHub #60) + * Improved: Use -fvisibility=hidden by default with supporting compilers, + e.g. GCC and Clang (GitHub #60) + * Changed: Migrated from GNU Autotools to CMake (GitHub #17, #47, #56, #59) + Thanks for their support with the CMake migration to: + - David Demelier + - Jørgen Ibsen + - KangLin + - Kouhei Sutou + - myd7349 + - Richard Hodges + - Zachary Lund + * Removed: All Windows-related build systems other than CMake + * Soname: 1:25:0 + +2019-01-02 -- 0.9.1 + +>>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + * Fixed: [CVE-2018-20721] + Out-of-bounds read in uriParse*Ex* for incomplete URIs with IPv6 + addresses with embedded IPv4 address, e.g. "//[::44.1"; + mitigated if passed parameter <afterLast> points to readable memory + containing a '\0' byte. + Commit cef25028de5ff872c2e1f0a6c562eb3ea9ecbce4 + Thanks to Joergen Ibsen for the report! +>>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + * Fixed: When parsing a malformed URI with an IPvFuture address + (e.g. "http://[vA.123456" missing "]"), errorPos would point to the first + character after "v" than the actual position of the error (here: the end + of the string) + * Fixed: uriToStringCharsRequired* reported 1 more byte than actually needed + for IPv4 address URIs (GitHub #41); Thanks to @gyh007 for the patch! + * Fixed: Compilation with MinGW + Thanks to Sandro Mani for the patch! + * Fixed: Drop use of asprintf from the test suite for MinGW (GitHub #40) + * Improved: For parse errors, waterproof errorPos <= afterLast + * Soname: 1:24:0 + +2018-10-27 -- 0.9.0 + +>>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + * Fixed: [CVE-2018-19198] + Out-of-bounds write in uriComposeQuery* and uriComposeQueryEx* + Commit 864f5d4c127def386dd5cc926ad96934b297f04e + Thanks to Google Autofuzz team for the report! + * Fixed: [CVE-2018-19199] + Detect integer overflow in uriComposeQuery* and uriComposeQueryEx* + Commit f76275d4a91b28d687250525d3a0c5509bbd666f + Thanks to Google Autofuzz team for the report! + * Fixed: [CVE-2018-19200] + Protect uriResetUri* against acting on NULL input + Commit f58c25069cf4a986fe17a80c5b38687e31feb539 +>>>>>>>>>>>>> SECURITY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + * Fixed: Be fully compliant to C89 (Gitub #28) and C++98 in test code + * Fixed: Fix off-by-one in uriComposeQueryCharsRequired* and ...Ex* + Reported space requirements were 1 byte bigger than necessary + * Changed: Marked as deprecated: + Deprecated functions: + uriNormalizeSyntaxMaskRequired[AW] + uriParseUri[AW] + uriParseUriEx[AW] + * Added: Add convenience functions to ease user code to parse a single URI + New functions: + uriParseSingleUri[AW] + uriParseSingleUriEx[AW] + uriParseSingleUriExMm[AW] + * Added: Support for custom memory managers (GitHub #26, #35), see Doxygen + New functions (as extension of existing ones): + uriAddBaseUriExMm[AW] + uriComposeQueryMallocExMm[AW] + uriDissectQueryMallocExMm[AW] + uriFreeQueryListMm[AW] + uriFreeUriMembersMm[AW] + uriNormalizeSyntaxExMm[AW] + uriParseSingleUriExMm[AW] + uriRemoveBaseUriMm[AW] + New functions (for convenience): + uriCompleteMemoryManager + uriEmulateCalloc + uriEmulateReallocarray + uriTestMemoryManager + New error codes: + URI_ERROR_MEMORY_MANAGER_FAULTY + URI_ERROR_MEMORY_MANAGER_INCOMPLETE + New types: + UriFuncCalloc + UriFuncFree + UriFuncMalloc + UriFuncRealloc + UriFuncReallocarray + UriMemoryManager + * Added: Add non-void versions of uriNormalizeSyntaxMaskRequired* + New functions: + uriNormalizeSyntaxMaskRequiredEx[AW] + * Changed: Migrate test suite from CppTest to GoogleTest 1.8.1 + * Improved: Make test suite free of memory leaks (GitHub #31) + Thanks to AddressSanitizer! + * Removed: Support for pointless define URI_SIZEDOWN (GitHub #29) + Related configure option --enable-sizedown has also been removed. + * Soname: 1:23:0 + +2018-08-18 -- 0.8.6 + + * Fixed: Bad/NULL .hostText.afterLast when parsing certain rather pathologic + but well-formed URIs with empty host (e.g. "//:%aa@") (GitHub #15) + Thanks to Kurt Schwehr for the report! + * Fixed: Fix uriRemoveBaseUri for case where scheme, host name, + IPvFuture address or path segments of the source address were + string prefixes of the related counterpart in the base URI. + Thanks to Yang Yu for the patch! (GitHub #19, #20) + * Fixed: Make UriStringToUnixFilename and UriStringToWindowsFilename + support minimal representation a la RFC 8089, e.g. file:/bin/bash + (compare to file:///bin/bash with three slashes) (GitHub #12, #14) + Thanks to Zane van Iperen for the report! + * Fixed: Documentation typos (GitHub #10, #11) + Thanks to Graham Percival! + * Improved: Made API docs of uriRemoveBaseUri more clear + (related to GitHub #19) + * Soname: 1:22:0 + +2018-02-07 -- 0.8.5 + + * Changed: The uriparser project has moved from SourceForge to GitHub: + Code + issue tracker: https://github.com/uriparser/uriparser + New website: https://uriparser.github.io/ + Please update any links of yours, accordingly. Thank you! + * Fixed: Memleak in out-of-memory clean-up code + of URI normalization, related to SF.net bug #28. + Thanks to Chris Hills for the report! + * Fixed: Fix compilation of uriparse(1) on FreeBSD + Thanks to Ed Schouten for the patch! + * Fixed: Fix C90 compilation errors + Thanks to Joel Cunningham for the patches! + * Fixed: Space requirements documented for uriWindowsFilenameToUriStringA + given URI "file://server1/file1.txt" (SF.net bug #31) + Thanks to threedyd for the report! + * Fixed: Compiler warnings + Thanks to Joel Cunningham for the patches! + * Fixed: Stop exporting internal function RemoveBaseUriImpl + Thanks to Joel Cunningham for the report! + * Fixed: API documentation front page no longer empty with Doxygen 1.8.13 + * Fixed: "make -C doc install" fixed for lack of .map files + * Improved: Communicate that absolutePath is always URI_FALSE for URIs + with a host in uriparse CLI tool output and Uri.h header + (GitHub #2, SF.net #30) + * Soname: 1:21:0 + +2015-10-12 -- 0.8.4 + + * Fixed: Stack overflow on parsing malformed IPv6 addresses with + more than eigtht quads. Thanks to Alexander Klink for the report! + * Soname: 1:20:0 + +2015-10-04 -- 0.8.3 + + * Fixed: uriCompareRange reported NULL pointer and range of + length zero as equal, by mistake. + Thanks to Robert Kausch and his Coverity report. + * Fixed: Use-after-free in out-of-memory code of uriMakeOwner. + Thanks to Chris Hills and his Klocwork-based report (SF.net bug #28) + * Soname: 1:19:0 + +2015-04-27 -- 0.8.2 + + * Fixed: Broken conversion from/to Windows network shares (SF.net bug #21) + Thanks to Adam Gross and Dmitry Repkin! + * Fixed: Limit uriCompareRange return values to -1/0/1 (SF.net bug #24) + As a side effect, this fixes the test suite for AArch64. + Thanks to Marcin Juszkiewicz for the patch! + * Fixed: MinGW Makefile: + LIB_DIR fixed from ../../lib leftover to ../../src (SF.net bug #27) + Thanks to Dmytro Zagashev for the report! + * Fixed: Add missing NULL checks to UriStringToFilename (SF.net bug #25) + Thanks to Jerome Custodio for the report! + * Changed: Leave inlining decisions to GCC + * Soname: 1:18:0 + +2014-10-20 -- 0.8.1 + + * Fixed: Sync URI_VER_* preprocessor defines (were at 0.7.6, SF.net bug #23) + * Fixed: Bug in internal function that may flip uriEqualsUri results around + * Added: Function uriAddBaseUriEx allowing to resolve URIs with + a scheme identical to that of the base URI to resolve against + as if the URI to resolve had no scheme specified, when flag + URI_RESOLVE_IDENTICAL_SCHEME_COMPAT is specified + (SF.net feature request #4) + * Soname: 1:17:0 + +2014-07-12 -- 0.8.0.1 + + * Fixed: ISO C90 warnings (SF.net bug #20) + * Changed: No longer ship RFC documents (to make things easier for Debian) + * Soname: 1:16:0 + +2013-12-20 -- 0.8.0 + + * Fixed: Resolution of relative URI "/" broken + Thanks to Mo McRoberts for the patch! + * Fixed: uriAddBaseUri produced uriUri objects with both host + and the absolutePath flag set (while the absolutePath flag + should only be true for URI objects without a host) when + resolving absolute URIs like "/" or "/foo/bar". + Now the absolutePath flag is set to URI_FALSE and an empty + segment is added as necessary + * Fixed: .errorCode could end up unset, previously + Thanks to Radu Hociung for the patch! (SF.net bug #16) + * Fixed: Resolve use of non-POSIX "sed -r" used when building + documentation (SF.net bug #18) + Thanks to Ryan Schmidt for reporting! + * Fixed: Build DLL with -no-undefined on Windows + Thanks to Michel Zou for the patch! (SF.net bug #19) + * Added: Command line tool "uriparse" + Thanks to Radu Hociung for coding! (SF.net feature request #3) + * Soname: 1:15:0 + +2013-08-24 -- 0.7.9 + + * Fixed: Error position ended up as NULL for some syntax errors. + Thanks to Daniel Solano Gómez for the patch! (SF.net bug #14) + * Soname: 1:14:0 + +2013-05-13 -- 0.7.8 + + * Fixed: Fix dissection of query string "q=hello&x=&y=" (SF.net bug #12) + Thanks to Marc Novakowski for reporting! + * Soname: 1:13:0 + +2012-04-05 -- 0.7.7 + + * Fixed: Fix rejection of some valid characters for userinfo + section, e.g. "http://%2Fuser:%2F21@host/" (SF.net bug #11) + * Fixed: Fix rejection of valid double colon in userinfo + section, e.g. "http://::@host/" + * Soname: 1:12:0 + +2012-01-20 -- 0.7.6 + + * Fixed: Qt Compressed Help file was not installed + * Fixed: Shadow/VPATH build doc generation + * Fixed: Compile error from Doxygen when configuring with + neither --enable-doc nor --disable-doc + * Fixed: Code documentation errors + Thanks to Valentin Haenel for the patch! + * Fixed: Fix include path in pkg-config, i.e. remove + "/uriparser" suffix as uriparser's headers are meant to + be included by statements like #include <uriparser/....> . + Thanks to Philip de Nier for reporting! + * Fixed: Compilation in context of Eclipse + Cygwin + wchar_t + (SF.net bug #10) + Thanks to Gary Mazzaferro for reporting! + * Fixed: Selection of supported character widths at build + time: <char *> or <wchar_t *> or both + * Added: configure parameters to disable either character + widths: --disable-char, --disable-wchar_t + * Soname: 1:11:0 + +2009-03-04 -- 0.7.5 + + * Added: pkg-config file + * Fixed: File Doxyfile.in was missing from release archives + Thanks to Rakesh Pandit for reporting! + * Fixed: Doc generation troubles + * Changed: No longer shipping bundled libcpptest + * Changed: New dependencies: + - libcpptest 1.1.0 or later + - pkg-config + The libcpptest dependency can be disabled through + configuring with --disable-test, which excludes the + test suite from compilation. + * Soname: 1:10:0 + +2008-12-23 -- 0.7.4 + + * Fixed: Null pointer de-referencing when dissecting query + strings starting with "&" right after "?" (SF.net bug #7). + Thanks to Harvey Vrsalovic for reporting! + * Fixed: Memory leak in uriFreeQueryList function (SF.net bug #6) + Thanks to Daniel Chapiesky for reporting! + * Fixed: Memory leak in uriNormalizeSyntax(Ex) functions (SF.net bug #6) + Thanks to Daniel Chapiesky for reporting! + * Improved: Nested configure hacks resolved + * Soname: 1:9:0 + +2008-11-08 -- 0.7.3 + + * Fixed: Missing NULL check in parsing routines + Thanks to Sezai Tekin for reporting! + * Fixed: uriparser now builds on Cygwin + * Fixed: Now shipping gnulib's config.guess from HEAD + which is suitable for Haiku (SF.net bug #5) + * Changed: swprintf requirement resolved + * Changed: Build system changes: + - configure option --enable-doc added + - configure.in renamed to configure.ac + - some Autotools files moved to build-aux directory + * Added: Qt Assistant documentation output: + - Qt Compressed Help (.qch) at <doc/uriparser-doc-*.qch> + - Qt Help Project (.qhp) at <doc/html/index.qhp> + Generation requires Doxygen 1.5.7.1-20081103 or later. + * Soname: 1:8:0 + +2008-09-01 -- 0.7.2 + + * Fixed: Bad cleanup logic in functions + - uriAddBaseUri(..) + - uriRemoveBaseUri(..) + Previously you needed to call uriFreeUriMembers on return code + URI_ERROR_MALLOC and only then. So that's why these functions now + take cleanup off your shoulders. An extra call to uriFreeUriMembers + from your side is still needed in case of success. + * Soname: 1:7:0 + +2008-04-27 -- 0.7.1 + + * Fixed: Bogus syntax error when parsing URIs with port-like + passwords, e.g. "http://user:21@host/" (SF.net bug #1) + Thanks to Friedrich Delgado Friedrichs for reporting! + * Fixed: Parser did not handle trailing slashes correctly in some cases, + which also made the structures produced from parsing "http://e.com/" + and "http://e.com" indistinguishable. (SF.net bug #2) + Thanks to Edward Z. Yang for reporting! + +2008-04-04 -- 0.7.0 + + * Added: Dissection and composition of query strings + * Added: Documentation improvements + (in|out|inout indicators, addition of \since and \see) + * Changed: Code::Blocks project files updated from file format + version 1.4 to 1.6, which is produced by Code::Blocks 8.02 + * Added: Code::Blocks workspace file + * Soname: 1:5:0 + +2008-02-25 -- 0.6.4 + + * Added: Syntax-based normalization can now handle relative URIs, + e.g. "../../a/b/.././c" is normalized to "../../a/c" + * Fixed: Normalization code could free foreign memory + * Fixed: Normalization processed the path segment even when asked not to + * Added: MinGW Makefile and related readme + Thanks to Michael Anthony Puls II! + * Fixed: Documentation bug not requiring enough memory for the output + buffer when converting a relative file URI back to a filename + * Soname: 1:4:0 + +2008-02-11 -- 0.6.3 + + * Fixed: Two major crash bugs in normalization code + Thanks to Adrian Manrique for the patch! + * Added: Brief usage tutorial + * Soname: 1:3:0 + +2008-02-08 -- 0.6.2 + + * Fixed: Freeing a normalized URI like "http://test?" + caused a crash. Thanks to Adrian Manrique for reporting! + * Fixed: Filename <--> URI string conversion helpers can + now handle relative URIs and filenames + * Soname: 1:2:0 + +2007-12-23 -- 0.6.1 + + * Fixed: Percent-encodings in hostnames were not repaired during normalization. + Thanks to Adrian Manrique for reporting! + * Fixed: Percent-encodings were fixed after dot removal not before during + normalization. + Thanks to Adrian Manrique for reporting! + * Fixed: Include path order bug + Thanks to Ed Schouten for reporting this! + * Fixed: Shadow builds now possible + Thanks to Adeodato Simó for the patch! + * Added: Version guards for Autoconf/Automake + Thanks to Martin Michlmayr for reporting! + * Soname: 1:1:0 + +2007-09-17 -- 0.6.0 + + * Fixed: Proper soname updates from now on, starting at 1:0:0 + * Removed: Visual Studio 2003 project files + +2007-09-13 -- 0.5.2 + + * Added: RemoveBaseUri function to create URI references + * Added: Unix/Windows filename <--> URI string conversion helpers + * Added: EscapeEx function to escape text blocks without zero termination + * Fixed: Bug in ToString for URIs with scheme, path, but no host (e.g. "f:/.//g") + * Fixed: AddBase now resolves ".//g" with base "f:/a" to "f:/.//g" instead of + "f://g" which would result in "g" becoming the authority part when parsing + a recomposition (ToString) of that URI structure. This is a whole in RFC 3986, + see http://lists.w3.org/Archives/Public/uri/2007Aug/0003.html for details. + +2007-08-09 -- 0.5.1 + + * Fixed: Empty host bug (URIs like "///g") + * Fixed: Relative URIs are no longer touched by normalization + * Fixed: MergePath failed for empty paths + * Fixed: Bug with "." segments in AddBase + All of the above revealed by test cases from 4Suite (http://4suite.org/) + +2007-07-28 -- 0.5.0 + + * Added: Syntax-based normalization + * Added: Percent-encoding function Escape + * Improved: Malloc/NULL checks added + * Added: New function UnescapeInPlaceEx can also decode '+' to ' ' + and convert line breaks + * Added: Exact space computation for ToString, see ToStringCharsRequired + * Added: --enable-sizedown for saving space and slower code + * Fixed: Two internal functions were exposed in the API by mistake: + uriPushToStack and uriStackToOctet + * Added: Visual Studio 2005 project files + * Removed: Legacy code (removal was announced for 0.5.0) + +2007-07-06 -- 0.4.1 + + * Fixed: ToString did not work for IPv4 and IPv6 hosts + +2007-07-03 -- 0.4.0 + + * Added: References resolution (think relative to absolute) + * Added: Naive URI equality check + * Added: URIs can now be converted back to strings + * Fixed: The first path segment of a relative URI was eaten + (functions ParseSegmentNz and ParseMustBeSegmentNzNc) + * Fixed: uri->scheme.first was not reset in some cases + (function ParseMustBeSegmentNzNc) + * Improved: Test suite now built on "make check", not before + * Fixed: Test suite always returned 0 (success) + +2007-04-23 -- 0.3.4 + + * Added: Shared library support (moved to libtool) + +2007-04-03 -- 0.3.3 + + * Fixed: Now unix EOLs constantly + * Fixed: Added forgotten files to release package + +2007-03-31 -- 0.3.2 + + * Fixed: Now compiles on FreeBSD + +2007-03-28 -- 0.3.1 + + * Fixed: Now compiles on Mac OS X + +2007-03-26 -- 0.3.0 + + * Added: New API, old marked deprecated * Added: Added support for wide strings (think wchar_t) - * Added: Doxygen code documentation - * Added: Test suite using CppTest - * Changed: Library code is now licensed under the new BSD license. - The test suite code is licensed under LGPL. - -2006-12-08 -- 0.2.1 + * Added: Doxygen code documentation + * Added: Test suite using CppTest + * Changed: Library code is now licensed under the new BSD license. + The test suite code is licensed under LGPL. + +2006-12-08 -- 0.2.1 diff --git a/contrib/restricted/uriparser/GOALS.txt b/contrib/restricted/uriparser/GOALS.txt index 1ed9037db0..5ad29adfe8 100644 --- a/contrib/restricted/uriparser/GOALS.txt +++ b/contrib/restricted/uriparser/GOALS.txt @@ -1,46 +1,46 @@ -== Requirements == - (1) URI parser fully conforming to the - latest URI RFC. Currently this is RFC 3986: - http://tools.ietf.org/html/rfc3986 - - (2) Based on an LL(1) grammar, at least mainly. - Not using a jump table but one function per - rule instead. - - (3) Library licensed under "New BSD license". - http://www.opensource.org/licenses/bsd-license.php - Test suite code licensed under LGPL. - http://www.opensource.org/licenses/lgpl-license.php - - (4) Written in ANSI/ISO C. - - (5) Portable. Must compile with GCC, MinGW, - Visual Studio 200[35]. - - (6) "OOP-C" -> thread safe, no shared globals - between two parser "instances" - - (7) Support for <char> and <wchar_t> without internal - conversion. Two versions of all functions - from the public interface. - - (8) Doxygen Code documentation at least for all - interface functions and structures. - http://www.stack.nl/~dimitri/doxygen/index.html - - (9) Sun Java code conventions for all C/C++ code. - http://java.sun.com/docs/codeconv/ - -(10) #include "xxx" for files in same folder. - #include <xxx> for files from include folders. - -(11) Use GoogleTest for unit testing. - https://github.com/google/googletest - -(12) Implement algorithm for reference resolution - -(13) Implement algorithm for normalization and - comparison - -== Optional goals == - (A) C++ Wrapper classes (uriparser++?) +== Requirements == + (1) URI parser fully conforming to the + latest URI RFC. Currently this is RFC 3986: + http://tools.ietf.org/html/rfc3986 + + (2) Based on an LL(1) grammar, at least mainly. + Not using a jump table but one function per + rule instead. + + (3) Library licensed under "New BSD license". + http://www.opensource.org/licenses/bsd-license.php + Test suite code licensed under LGPL. + http://www.opensource.org/licenses/lgpl-license.php + + (4) Written in ANSI/ISO C. + + (5) Portable. Must compile with GCC, MinGW, + Visual Studio 200[35]. + + (6) "OOP-C" -> thread safe, no shared globals + between two parser "instances" + + (7) Support for <char> and <wchar_t> without internal + conversion. Two versions of all functions + from the public interface. + + (8) Doxygen Code documentation at least for all + interface functions and structures. + http://www.stack.nl/~dimitri/doxygen/index.html + + (9) Sun Java code conventions for all C/C++ code. + http://java.sun.com/docs/codeconv/ + +(10) #include "xxx" for files in same folder. + #include <xxx> for files from include folders. + +(11) Use GoogleTest for unit testing. + https://github.com/google/googletest + +(12) Implement algorithm for reference resolution + +(13) Implement algorithm for normalization and + comparison + +== Optional goals == + (A) C++ Wrapper classes (uriparser++?) diff --git a/contrib/restricted/uriparser/README.md b/contrib/restricted/uriparser/README.md index 2846e9d042..49bb53f863 100644 --- a/contrib/restricted/uriparser/README.md +++ b/contrib/restricted/uriparser/README.md @@ -1,87 +1,87 @@ [![Build and test](https://github.com/uriparser/uriparser/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/uriparser/uriparser/actions/workflows/build-and-test.yml) -[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/uriparseradmin/uriparser?svg=true)](https://ci.appveyor.com/project/uriparseradmin/uriparser) - - -# uriparser - -uriparser is a -strictly [RFC 3986](http://tools.ietf.org/html/rfc3986) compliant -URI parsing and handling library -written in C89 ("ANSI C"). -uriparser is cross-platform, -fast, +[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/uriparseradmin/uriparser?svg=true)](https://ci.appveyor.com/project/uriparseradmin/uriparser) + + +# uriparser + +uriparser is a +strictly [RFC 3986](http://tools.ietf.org/html/rfc3986) compliant +URI parsing and handling library +written in C89 ("ANSI C"). +uriparser is cross-platform, +fast, supports both `char` and `wchar_t`, and -is licensed under the [New BSD license](https://github.com/uriparser/uriparser/blob/master/COPYING). - -To learn more about uriparser, -please check out [https://uriparser.github.io/](https://uriparser.github.io/). - - -# Example use from an existing CMake project - -```cmake +is licensed under the [New BSD license](https://github.com/uriparser/uriparser/blob/master/COPYING). + +To learn more about uriparser, +please check out [https://uriparser.github.io/](https://uriparser.github.io/). + + +# Example use from an existing CMake project + +```cmake cmake_minimum_required(VERSION 3.3) - + project(hello VERSION 1.0.0) -find_package(uriparser 0.9.2 CONFIG REQUIRED char wchar_t) - -add_executable(hello - hello.c -) - -target_link_libraries(hello PUBLIC uriparser::uriparser) -``` - - -# Compilation - -## Compilation (standalone, GNU make, Linux) -```console -# mkdir build -# cd build -# cmake -DCMAKE_BUILD_TYPE=Release .. # see CMakeLists.txt for options -# make -# make test -# make install -``` - -## Available CMake options (and defaults) -```console -# rm -f CMakeCache.txt ; cmake -LH . | grep -B1 ':.*=' | sed 's,--,,' -// Build shared libraries (rather than static ones) -BUILD_SHARED_LIBS:BOOL=ON - -// Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ... -CMAKE_BUILD_TYPE:STRING= - -// Install path prefix, prepended onto install directories. -CMAKE_INSTALL_PREFIX:PATH=/usr/local - +find_package(uriparser 0.9.2 CONFIG REQUIRED char wchar_t) + +add_executable(hello + hello.c +) + +target_link_libraries(hello PUBLIC uriparser::uriparser) +``` + + +# Compilation + +## Compilation (standalone, GNU make, Linux) +```console +# mkdir build +# cd build +# cmake -DCMAKE_BUILD_TYPE=Release .. # see CMakeLists.txt for options +# make +# make test +# make install +``` + +## Available CMake options (and defaults) +```console +# rm -f CMakeCache.txt ; cmake -LH . | grep -B1 ':.*=' | sed 's,--,,' +// Build shared libraries (rather than static ones) +BUILD_SHARED_LIBS:BOOL=ON + +// Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ... +CMAKE_BUILD_TYPE:STRING= + +// Install path prefix, prepended onto install directories. +CMAKE_INSTALL_PREFIX:PATH=/usr/local + // Path to qhelpgenerator program (default: auto-detect) QHG_LOCATION:FILEPATH= - -// Build code supporting data type 'char' -URIPARSER_BUILD_CHAR:BOOL=ON - -// Build API documentation (requires Doxygen, Graphviz, and (optional) Qt's qhelpgenerator) -URIPARSER_BUILD_DOCS:BOOL=ON - -// Build test suite (requires GTest >=1.8.0) -URIPARSER_BUILD_TESTS:BOOL=ON - -// Build tools (e.g. CLI "uriparse") -URIPARSER_BUILD_TOOLS:BOOL=ON - -// Build code supporting data type 'wchar_t' -URIPARSER_BUILD_WCHAR_T:BOOL=ON - -// Enable installation of uriparser -URIPARSER_ENABLE_INSTALL:BOOL=ON - -// Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC -URIPARSER_MSVC_RUNTIME:STRING= + +// Build code supporting data type 'char' +URIPARSER_BUILD_CHAR:BOOL=ON + +// Build API documentation (requires Doxygen, Graphviz, and (optional) Qt's qhelpgenerator) +URIPARSER_BUILD_DOCS:BOOL=ON + +// Build test suite (requires GTest >=1.8.0) +URIPARSER_BUILD_TESTS:BOOL=ON + +// Build tools (e.g. CLI "uriparse") +URIPARSER_BUILD_TOOLS:BOOL=ON + +// Build code supporting data type 'wchar_t' +URIPARSER_BUILD_WCHAR_T:BOOL=ON + +// Enable installation of uriparser +URIPARSER_ENABLE_INSTALL:BOOL=ON + +// Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC +URIPARSER_MSVC_RUNTIME:STRING= // Treat all compiler warnings as errors URIPARSER_WARNINGS_AS_ERRORS:BOOL=OFF -``` +``` diff --git a/contrib/restricted/uriparser/THANKS b/contrib/restricted/uriparser/THANKS deleted file mode 100644 index c696f93e9e..0000000000 --- a/contrib/restricted/uriparser/THANKS +++ /dev/null @@ -1,67 +0,0 @@ -Adam Frisby -Adam Gross -Adeodato Sim -Adrian Manrique -Alexander Klink -Alexander Richardson -Arkadiusz Miskiewicz -Andreas Sturmlechner -Blair Sadewitz -Chris Hills -Cristian Rodriguez -Dan Pape -Daniel Chapiesky -Daniel Solano Gómez -David Demelier -Dennis Veatch -Dmitry Repkin -Dmytro Zagashev -Dr. Michael Lauer -Ed Schouten -Edward Z. Yang -Eren Trkay -Fabrice Fontaine -Friedrich Delgado Friedrichs -Gary Mazzaferro -Graham Percival -Harvey Vrsalovic -jensenrichardson -Jerome Custodio -Joel Cunningham -Jørgen Ibsen -Juan Pablo Gonzlez Tognarelli -KangLin -Karel Kočí -Kouhei Sutou -Kurt Schwehr -Marc Novakowski -Marcin Juszkiewicz -Martin Michlmayr -Michael Anthony Puls II -Michelino Chionchio -Michel Zou -Mo McRoberts -myd7349 -Periklis Akritidis -Philip de Nier -Radu Hociung -Rafael Fontenelle -Ralf S. Engelschall -Rakesh Pandit -Ren Rebe -Richard Hodges -Robert Buchholz -Robert Kausch -Ryan Schmidt -Sandro Mani -Schrijvers Luc -Scott Donelan -Sezai Tekin -Shehzan Mohammed -SpaceIm -Valentin Haenel -Vitaly Lipatov -Yang Yu -Wouter Beek -Zachary Lund -Zane van Iperen diff --git a/contrib/restricted/uriparser/TODO.txt b/contrib/restricted/uriparser/TODO.txt index d3df73b156..cd432aa0f8 100644 --- a/contrib/restricted/uriparser/TODO.txt +++ b/contrib/restricted/uriparser/TODO.txt @@ -1,30 +1,30 @@ -== BEFORE NEXT RELEASE == - * Look for more bad cleanup logic - -== SOON == - * migrate structures to d-pointers to - - hide low-level details - - improve ABI compatibility - * try to remove need for free after parser fail? - * add more responsibility/ownership/init info to docs - * samba filename conversion? - * (g/s)etters for single components? - * Add example "uritool": - * uritool check <uri> - * uritool getHost <uri> - * uritool setHost <host> <uri> - * ... - * Filename helpers - * samba shares - * pipe characters? C:/C| - * Test owner code - * Implement CleanBase (strips off last component, query and stuff) - * Implement Clone - * Test Equals - * Code TODOs - * Make hostText from hostData? - -== LATER == - * Enable/disable single components/algorithms? - * Pretty/smarter IPv6 stringification - * Reduce recursion, replace some by loops +== BEFORE NEXT RELEASE == + * Look for more bad cleanup logic + +== SOON == + * migrate structures to d-pointers to + - hide low-level details + - improve ABI compatibility + * try to remove need for free after parser fail? + * add more responsibility/ownership/init info to docs + * samba filename conversion? + * (g/s)etters for single components? + * Add example "uritool": + * uritool check <uri> + * uritool getHost <uri> + * uritool setHost <host> <uri> + * ... + * Filename helpers + * samba shares + * pipe characters? C:/C| + * Test owner code + * Implement CleanBase (strips off last component, query and stuff) + * Implement Clone + * Test Equals + * Code TODOs + * Make hostText from hostData? + +== LATER == + * Enable/disable single components/algorithms? + * Pretty/smarter IPv6 stringification + * Reduce recursion, replace some by loops diff --git a/contrib/restricted/uriparser/config.h b/contrib/restricted/uriparser/config.h index ebb62f778d..64d29ce835 100644 --- a/contrib/restricted/uriparser/config.h +++ b/contrib/restricted/uriparser/config.h @@ -1,51 +1,51 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2018, Sebastian Pipping <sebastian@pipping.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(URI_CONFIG_H) -# define URI_CONFIG_H 1 +/* + * uriparser - RFC 3986 URI parsing library + * + * Copyright (C) 2018, Sebastian Pipping <sebastian@pipping.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if !defined(URI_CONFIG_H) +# define URI_CONFIG_H 1 #define PACKAGE_VERSION "0.9.6" -#define HAVE_WPRINTF +#define HAVE_WPRINTF #define HAVE_REALLOCARRAY -#endif /* !defined(URI_CONFIG_H) */ +#endif /* !defined(URI_CONFIG_H) */ diff --git a/contrib/restricted/uriparser/include/uriparser/Uri.h b/contrib/restricted/uriparser/include/uriparser/Uri.h index ea4a913029..52b648d001 100644 --- a/contrib/restricted/uriparser/include/uriparser/Uri.h +++ b/contrib/restricted/uriparser/include/uriparser/Uri.h @@ -6,32 +6,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -218,7 +218,7 @@ typedef struct URI_TYPE(QueryListStruct) { * @since 0.3.0 * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriExA (with "Single"). */ -URI_PUBLIC int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, +URI_PUBLIC int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast); @@ -238,7 +238,7 @@ URI_PUBLIC int URI_FUNC(ParseUriEx)(URI_TYPE(ParserState) * state, * @since 0.3.0 * @deprecated Deprecated since 0.9.0, please migrate to uriParseSingleUriA (with "Single"). */ -URI_PUBLIC int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, +URI_PUBLIC int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, const URI_CHAR * text); @@ -260,8 +260,8 @@ URI_PUBLIC int URI_FUNC(ParseUri)(URI_TYPE(ParserState) * state, * @see uriToStringA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, - const URI_CHAR * text, const URI_CHAR ** errorPos); +URI_PUBLIC int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, + const URI_CHAR * text, const URI_CHAR ** errorPos); @@ -285,7 +285,7 @@ URI_PUBLIC int URI_FUNC(ParseSingleUri)(URI_TYPE(Uri) * uri, * @see uriToStringA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, +URI_PUBLIC int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, const URI_CHAR * first, const URI_CHAR * afterLast, const URI_CHAR ** errorPos); @@ -311,7 +311,7 @@ URI_PUBLIC int URI_FUNC(ParseSingleUriEx)(URI_TYPE(Uri) * uri, * @see uriToStringA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, +URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, const URI_CHAR * first, const URI_CHAR * afterLast, const URI_CHAR ** errorPos, UriMemoryManager * memory); @@ -328,7 +328,7 @@ URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, * @see uriFreeUriMembersMmA * @since 0.3.0 */ -URI_PUBLIC void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); +URI_PUBLIC void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); @@ -344,7 +344,7 @@ URI_PUBLIC void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); * @see uriFreeUriMembersA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, +URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory); @@ -368,7 +368,7 @@ URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri, * @see uriUnescapeInPlaceExA * @since 0.5.2 */ -URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, +URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, const URI_CHAR * inAfterLast, URI_CHAR * out, UriBool spaceToPlus, UriBool normalizeBreaks); @@ -392,7 +392,7 @@ URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, * @see uriUnescapeInPlaceA * @since 0.5.0 */ -URI_PUBLIC URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, +URI_PUBLIC URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, UriBool spaceToPlus, UriBool normalizeBreaks); @@ -414,7 +414,7 @@ URI_PUBLIC URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, * @see uriEscapeExA * @since 0.5.0 */ -URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, +URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, UriBool plusToSpace, UriBreakConversion breakConversion); @@ -437,7 +437,7 @@ URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, * @see uriEscapeA * @since 0.3.0 */ -URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout); +URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout); @@ -458,7 +458,7 @@ URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout); * @see uriAddBaseUriExMmA * @since 0.4.0 */ -URI_PUBLIC int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, +URI_PUBLIC int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, const URI_TYPE(Uri) * relativeSource, const URI_TYPE(Uri) * absoluteBase); @@ -481,7 +481,7 @@ URI_PUBLIC int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, * @see uriAddBaseUriExMmA * @since 0.8.1 */ -URI_PUBLIC int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absoluteDest, +URI_PUBLIC int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absoluteDest, const URI_TYPE(Uri) * relativeSource, const URI_TYPE(Uri) * absoluteBase, UriResolutionOptions options); @@ -506,7 +506,7 @@ URI_PUBLIC int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absoluteDest, * @see uriAddBaseUriExA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absoluteDest, +URI_PUBLIC int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absoluteDest, const URI_TYPE(Uri) * relativeSource, const URI_TYPE(Uri) * absoluteBase, UriResolutionOptions options, UriMemoryManager * memory); @@ -535,7 +535,7 @@ URI_PUBLIC int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absoluteDest, * @see uriAddBaseUriExMmA * @since 0.5.2 */ -URI_PUBLIC int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, +URI_PUBLIC int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, const URI_TYPE(Uri) * absoluteSource, const URI_TYPE(Uri) * absoluteBase, UriBool domainRootMode); @@ -564,7 +564,7 @@ URI_PUBLIC int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, * @see uriAddBaseUriExMmA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, +URI_PUBLIC int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, const URI_TYPE(Uri) * absoluteSource, const URI_TYPE(Uri) * absoluteBase, UriBool domainRootMode, UriMemoryManager * memory); @@ -582,8 +582,8 @@ URI_PUBLIC int URI_FUNC(RemoveBaseUriMm)(URI_TYPE(Uri) * dest, * * @since 0.4.0 */ -URI_PUBLIC UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, - const URI_TYPE(Uri) * b); +URI_PUBLIC UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, + const URI_TYPE(Uri) * b); @@ -599,7 +599,7 @@ URI_PUBLIC UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, * @see uriToStringA * @since 0.5.0 */ -URI_PUBLIC int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri, +URI_PUBLIC int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri, int * charsRequired); @@ -617,8 +617,8 @@ URI_PUBLIC int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri, * @see uriToStringCharsRequiredA * @since 0.4.0 */ -URI_PUBLIC int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, - int maxChars, int * charsWritten); +URI_PUBLIC int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, + int maxChars, int * charsWritten); @@ -635,8 +635,8 @@ URI_PUBLIC int URI_FUNC(ToString)(URI_CHAR * dest, const URI_TYPE(Uri) * uri, * @since 0.5.0 * @deprecated Deprecated since 0.9.0, please migrate to uriNormalizeSyntaxMaskRequiredExA (with "Ex"). */ -URI_PUBLIC unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)( - const URI_TYPE(Uri) * uri); +URI_PUBLIC unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)( + const URI_TYPE(Uri) * uri); @@ -653,8 +653,8 @@ URI_PUBLIC unsigned int URI_FUNC(NormalizeSyntaxMaskRequired)( * @see uriNormalizeSyntaxMaskRequiredA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxMaskRequiredEx)( - const URI_TYPE(Uri) * uri, unsigned int * outMask); +URI_PUBLIC int URI_FUNC(NormalizeSyntaxMaskRequiredEx)( + const URI_TYPE(Uri) * uri, unsigned int * outMask); @@ -675,8 +675,8 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntaxMaskRequiredEx)( * @see uriNormalizeSyntaxMaskRequiredA * @since 0.5.0 */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, - unsigned int mask); +URI_PUBLIC int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, + unsigned int mask); @@ -697,8 +697,8 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntaxEx)(URI_TYPE(Uri) * uri, * @see uriNormalizeSyntaxMaskRequiredA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, - unsigned int mask, UriMemoryManager * memory); +URI_PUBLIC int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, + unsigned int mask, UriMemoryManager * memory); @@ -717,7 +717,7 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntaxExMm)(URI_TYPE(Uri) * uri, * @see uriNormalizeSyntaxMaskRequiredA * @since 0.5.0 */ -URI_PUBLIC int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); +URI_PUBLIC int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); @@ -739,7 +739,7 @@ URI_PUBLIC int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); * @see uriWindowsFilenameToUriStringA * @since 0.5.2 */ -URI_PUBLIC int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, +URI_PUBLIC int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, URI_CHAR * uriString); @@ -762,7 +762,7 @@ URI_PUBLIC int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, * @see uriUnixFilenameToUriStringA * @since 0.5.2 */ -URI_PUBLIC int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, +URI_PUBLIC int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, URI_CHAR * uriString); @@ -781,7 +781,7 @@ URI_PUBLIC int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, * @see uriUriStringToWindowsFilenameA * @since 0.5.2 */ -URI_PUBLIC int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, +URI_PUBLIC int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, URI_CHAR * filename); @@ -800,7 +800,7 @@ URI_PUBLIC int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, * @see uriUriStringToUnixFilenameA * @since 0.5.2 */ -URI_PUBLIC int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, +URI_PUBLIC int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, URI_CHAR * filename); @@ -819,8 +819,8 @@ URI_PUBLIC int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, * @see uriComposeQueryA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)( - const URI_TYPE(QueryList) * queryList, int * charsRequired); +URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)( + const URI_TYPE(QueryList) * queryList, int * charsRequired); @@ -839,8 +839,8 @@ URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequired)( * @see uriComposeQueryExA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequiredEx)( - const URI_TYPE(QueryList) * queryList, +URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequiredEx)( + const URI_TYPE(QueryList) * queryList, int * charsRequired, UriBool spaceToPlus, UriBool normalizeBreaks); @@ -867,7 +867,7 @@ URI_PUBLIC int URI_FUNC(ComposeQueryCharsRequiredEx)( * @see uriDissectQueryMallocExMmA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQuery)(URI_CHAR * dest, +URI_PUBLIC int URI_FUNC(ComposeQuery)(URI_CHAR * dest, const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten); @@ -894,7 +894,7 @@ URI_PUBLIC int URI_FUNC(ComposeQuery)(URI_CHAR * dest, * @see uriDissectQueryMallocExMmA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryEx)(URI_CHAR * dest, +URI_PUBLIC int URI_FUNC(ComposeQueryEx)(URI_CHAR * dest, const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten, UriBool spaceToPlus, UriBool normalizeBreaks); @@ -920,7 +920,7 @@ URI_PUBLIC int URI_FUNC(ComposeQueryEx)(URI_CHAR * dest, * @see uriDissectQueryMallocExMmA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryMalloc)(URI_CHAR ** dest, +URI_PUBLIC int URI_FUNC(ComposeQueryMalloc)(URI_CHAR ** dest, const URI_TYPE(QueryList) * queryList); @@ -945,7 +945,7 @@ URI_PUBLIC int URI_FUNC(ComposeQueryMalloc)(URI_CHAR ** dest, * @see uriDissectQueryMallocExMmA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryMallocEx)(URI_CHAR ** dest, +URI_PUBLIC int URI_FUNC(ComposeQueryMallocEx)(URI_CHAR ** dest, const URI_TYPE(QueryList) * queryList, UriBool spaceToPlus, UriBool normalizeBreaks); @@ -971,7 +971,7 @@ URI_PUBLIC int URI_FUNC(ComposeQueryMallocEx)(URI_CHAR ** dest, * @see uriDissectQueryMallocExMmA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest, +URI_PUBLIC int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest, const URI_TYPE(QueryList) * queryList, UriBool spaceToPlus, UriBool normalizeBreaks, UriMemoryManager * memory); @@ -996,8 +996,8 @@ URI_PUBLIC int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest, * @see uriFreeQueryListMmA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast); +URI_PUBLIC int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) ** dest, + int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast); @@ -1019,8 +1019,8 @@ URI_PUBLIC int URI_FUNC(DissectQueryMalloc)(URI_TYPE(QueryList) ** dest, * @see uriFreeQueryListA * @since 0.7.0 */ -URI_PUBLIC int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, +URI_PUBLIC int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) ** dest, + int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, UriBool plusToSpace, UriBreakConversion breakConversion); @@ -1044,8 +1044,8 @@ URI_PUBLIC int URI_FUNC(DissectQueryMallocEx)(URI_TYPE(QueryList) ** dest, * @see uriFreeQueryListMmA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) ** dest, - int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, +URI_PUBLIC int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) ** dest, + int * itemCount, const URI_CHAR * first, const URI_CHAR * afterLast, UriBool plusToSpace, UriBreakConversion breakConversion, UriMemoryManager * memory); @@ -1060,7 +1060,7 @@ URI_PUBLIC int URI_FUNC(DissectQueryMallocExMm)(URI_TYPE(QueryList) ** dest, * @see uriFreeQueryListMmA * @since 0.7.0 */ -URI_PUBLIC void URI_FUNC(FreeQueryList)(URI_TYPE(QueryList) * queryList); +URI_PUBLIC void URI_FUNC(FreeQueryList)(URI_TYPE(QueryList) * queryList); @@ -1075,45 +1075,45 @@ URI_PUBLIC void URI_FUNC(FreeQueryList)(URI_TYPE(QueryList) * queryList); * @see uriFreeQueryListA * @since 0.9.0 */ -URI_PUBLIC int URI_FUNC(FreeQueryListMm)(URI_TYPE(QueryList) * queryList, +URI_PUBLIC int URI_FUNC(FreeQueryListMm)(URI_TYPE(QueryList) * queryList, UriMemoryManager * memory); -/** - * Makes the %URI hold copies of strings so that it no longer depends - * on the original %URI string. If the %URI is already owner of copies, - * this function returns <c>URI_TRUE</c> and does not modify the %URI further. - * - * Uses default libc-based memory manager. - * - * @param uri <b>INOUT</b>: %URI to make independent - * @return Error code or 0 on success - * - * @see uriMakeOwnerMmA - * @since 0.9.4 - */ -URI_PUBLIC int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri); - - - -/** - * Makes the %URI hold copies of strings so that it no longer depends - * on the original %URI string. If the %URI is already owner of copies, - * this function returns <c>URI_TRUE</c> and does not modify the %URI further. - * - * @param uri <b>INOUT</b>: %URI to make independent - * @param memory <b>IN</b>: Memory manager to use, NULL for default libc - * @return Error code or 0 on success - * - * @see uriMakeOwnerA - * @since 0.9.4 - */ -URI_PUBLIC int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, - UriMemoryManager * memory); - - - +/** + * Makes the %URI hold copies of strings so that it no longer depends + * on the original %URI string. If the %URI is already owner of copies, + * this function returns <c>URI_TRUE</c> and does not modify the %URI further. + * + * Uses default libc-based memory manager. + * + * @param uri <b>INOUT</b>: %URI to make independent + * @return Error code or 0 on success + * + * @see uriMakeOwnerMmA + * @since 0.9.4 + */ +URI_PUBLIC int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri); + + + +/** + * Makes the %URI hold copies of strings so that it no longer depends + * on the original %URI string. If the %URI is already owner of copies, + * this function returns <c>URI_TRUE</c> and does not modify the %URI further. + * + * @param uri <b>INOUT</b>: %URI to make independent + * @param memory <b>IN</b>: Memory manager to use, NULL for default libc + * @return Error code or 0 on success + * + * @see uriMakeOwnerA + * @since 0.9.4 + */ +URI_PUBLIC int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, + UriMemoryManager * memory); + + + #ifdef __cplusplus } #endif diff --git a/contrib/restricted/uriparser/include/uriparser/UriBase.h b/contrib/restricted/uriparser/include/uriparser/UriBase.h index 2e63f92c86..65e3b92e7d 100644 --- a/contrib/restricted/uriparser/include/uriparser/UriBase.h +++ b/contrib/restricted/uriparser/include/uriparser/UriBase.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -97,30 +97,30 @@ -/* Import/export decorator */ -#define URI_STATIC_BUILD -#if defined(URI_STATIC_BUILD) -# define URI_PUBLIC -#else -# if defined(URI_LIBRARY_BUILD) -# if defined(_MSC_VER) -# define URI_PUBLIC __declspec(dllexport) -# elif defined(URI_VISIBILITY) -# define URI_PUBLIC __attribute__ ((visibility("default"))) -# else -# define URI_PUBLIC -# endif -# else -# if defined(_MSC_VER) -# define URI_PUBLIC __declspec(dllimport) -# else -# define URI_PUBLIC -# endif -# endif -#endif - - - +/* Import/export decorator */ +#define URI_STATIC_BUILD +#if defined(URI_STATIC_BUILD) +# define URI_PUBLIC +#else +# if defined(URI_LIBRARY_BUILD) +# if defined(_MSC_VER) +# define URI_PUBLIC __declspec(dllexport) +# elif defined(URI_VISIBILITY) +# define URI_PUBLIC __attribute__ ((visibility("default"))) +# else +# define URI_PUBLIC +# endif +# else +# if defined(_MSC_VER) +# define URI_PUBLIC __declspec(dllimport) +# else +# define URI_PUBLIC +# endif +# endif +#endif + + + typedef int UriBool; /**< Boolean type */ #define URI_TRUE 1 @@ -307,7 +307,7 @@ typedef enum UriResolutionOptionsEnum { * @see UriMemoryManager * @since 0.9.0 */ -URI_PUBLIC int uriCompleteMemoryManager(UriMemoryManager * memory, +URI_PUBLIC int uriCompleteMemoryManager(UriMemoryManager * memory, UriMemoryManager * backend); @@ -326,7 +326,7 @@ URI_PUBLIC int uriCompleteMemoryManager(UriMemoryManager * memory, * @see UriMemoryManager * @since 0.9.0 */ -URI_PUBLIC void * uriEmulateCalloc(UriMemoryManager * memory, +URI_PUBLIC void * uriEmulateCalloc(UriMemoryManager * memory, size_t nmemb, size_t size); @@ -346,7 +346,7 @@ URI_PUBLIC void * uriEmulateCalloc(UriMemoryManager * memory, * @see UriMemoryManager * @since 0.9.0 */ -URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, +URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, void * ptr, size_t nmemb, size_t size); @@ -371,7 +371,7 @@ URI_PUBLIC void * uriEmulateReallocarray(UriMemoryManager * memory, * @see UriMemoryManager * @since 0.9.0 */ -URI_PUBLIC int uriTestMemoryManager(UriMemoryManager * memory); +URI_PUBLIC int uriTestMemoryManager(UriMemoryManager * memory); diff --git a/contrib/restricted/uriparser/include/uriparser/UriDefsAnsi.h b/contrib/restricted/uriparser/include/uriparser/UriDefsAnsi.h index af581b91a2..280dd286b3 100644 --- a/contrib/restricted/uriparser/include/uriparser/UriDefsAnsi.h +++ b/contrib/restricted/uriparser/include/uriparser/UriDefsAnsi.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/include/uriparser/UriDefsConfig.h b/contrib/restricted/uriparser/include/uriparser/UriDefsConfig.h index 51bc93eedd..e4a564883e 100644 --- a/contrib/restricted/uriparser/include/uriparser/UriDefsConfig.h +++ b/contrib/restricted/uriparser/include/uriparser/UriDefsConfig.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/include/uriparser/UriDefsUnicode.h b/contrib/restricted/uriparser/include/uriparser/UriDefsUnicode.h index 01421f5f86..f19f3a9031 100644 --- a/contrib/restricted/uriparser/include/uriparser/UriDefsUnicode.h +++ b/contrib/restricted/uriparser/include/uriparser/UriDefsUnicode.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/include/uriparser/UriIp4.h b/contrib/restricted/uriparser/include/uriparser/UriIp4.h index c2e59a6bf2..cca97258a4 100644 --- a/contrib/restricted/uriparser/include/uriparser/UriIp4.h +++ b/contrib/restricted/uriparser/include/uriparser/UriIp4.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -75,18 +75,18 @@ -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifndef URI_DOXYGEN -# include "UriBase.h" -#endif - - - +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifndef URI_DOXYGEN +# include "UriBase.h" +#endif + + + /** * Converts a IPv4 text representation into four bytes. * @@ -95,16 +95,16 @@ extern "C" { * @param afterLast Position to stop parsing at * @return Error code or 0 on success */ -URI_PUBLIC int URI_FUNC(ParseIpFourAddress)(unsigned char * octetOutput, +URI_PUBLIC int URI_FUNC(ParseIpFourAddress)(unsigned char * octetOutput, const URI_CHAR * first, const URI_CHAR * afterLast); -#ifdef __cplusplus -} -#endif - - - +#ifdef __cplusplus +} #endif + + + #endif +#endif diff --git a/contrib/restricted/uriparser/src/UriCommon.c b/contrib/restricted/uriparser/src/UriCommon.c index 7ba92f2495..493248251b 100644 --- a/contrib/restricted/uriparser/src/UriCommon.c +++ b/contrib/restricted/uriparser/src/UriCommon.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriCommon.h b/contrib/restricted/uriparser/src/UriCommon.h index 42311ddc98..9f6cee1ac8 100644 --- a/contrib/restricted/uriparser/src/UriCommon.h +++ b/contrib/restricted/uriparser/src/UriCommon.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriCompare.c b/contrib/restricted/uriparser/src/UriCompare.c index bca3db9236..423d6d365c 100644 --- a/contrib/restricted/uriparser/src/UriCompare.c +++ b/contrib/restricted/uriparser/src/UriCompare.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriEscape.c b/contrib/restricted/uriparser/src/UriEscape.c index ab8305fa97..9237422c7d 100644 --- a/contrib/restricted/uriparser/src/UriEscape.c +++ b/contrib/restricted/uriparser/src/UriEscape.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriFile.c b/contrib/restricted/uriparser/src/UriFile.c index 232957d3c8..6b7f5615f9 100644 --- a/contrib/restricted/uriparser/src/UriFile.c +++ b/contrib/restricted/uriparser/src/UriFile.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -67,10 +67,10 @@ -#include <stdlib.h> /* for size_t, avoiding stddef.h for older MSVCs */ - - - +#include <stdlib.h> /* for size_t, avoiding stddef.h for older MSVCs */ + + + static URI_INLINE int URI_FUNC(FilenameToUriString)(const URI_CHAR * filename, URI_CHAR * uriString, UriBool fromUnix) { const URI_CHAR * input = filename; @@ -96,7 +96,7 @@ static URI_INLINE int URI_FUNC(FilenameToUriString)(const URI_CHAR * filename, : is_windows_network ? _UT("file:") : _UT("file:///"); - const size_t prefixLen = URI_STRLEN(prefix); + const size_t prefixLen = URI_STRLEN(prefix); /* Copy prefix */ memcpy(uriString, prefix, prefixLen * sizeof(URI_CHAR)); diff --git a/contrib/restricted/uriparser/src/UriIp4.c b/contrib/restricted/uriparser/src/UriIp4.c index a794265269..d4878dcbee 100644 --- a/contrib/restricted/uriparser/src/UriIp4.c +++ b/contrib/restricted/uriparser/src/UriIp4.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriIp4Base.c b/contrib/restricted/uriparser/src/UriIp4Base.c index ded7c32c99..428e181880 100644 --- a/contrib/restricted/uriparser/src/UriIp4Base.c +++ b/contrib/restricted/uriparser/src/UriIp4Base.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriIp4Base.h b/contrib/restricted/uriparser/src/UriIp4Base.h index 4867850224..02245b8cbf 100644 --- a/contrib/restricted/uriparser/src/UriIp4Base.h +++ b/contrib/restricted/uriparser/src/UriIp4Base.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriMemory.c b/contrib/restricted/uriparser/src/UriMemory.c index baed2040da..aa8fe4a89e 100644 --- a/contrib/restricted/uriparser/src/UriMemory.c +++ b/contrib/restricted/uriparser/src/UriMemory.c @@ -5,32 +5,32 @@ * Copyright (C) 2018, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -42,9 +42,9 @@ * Holds memory manager implementation. */ -#include <config.h> +#include <config.h> -#ifdef HAVE_REALLOCARRAY +#ifdef HAVE_REALLOCARRAY # ifndef _GNU_SOURCE # define _GNU_SOURCE 1 # endif @@ -95,7 +95,7 @@ static void * uriDefaultRealloc(UriMemoryManager * URI_UNUSED(memory), static void * uriDefaultReallocarray(UriMemoryManager * URI_UNUSED(memory), void * ptr, size_t nmemb, size_t size) { -#ifdef HAVE_REALLOCARRAY +#ifdef HAVE_REALLOCARRAY return reallocarray(ptr, nmemb, size); #else const size_t total_size = nmemb * size; diff --git a/contrib/restricted/uriparser/src/UriMemory.h b/contrib/restricted/uriparser/src/UriMemory.h index a930f93ac3..193f9f00f2 100644 --- a/contrib/restricted/uriparser/src/UriMemory.h +++ b/contrib/restricted/uriparser/src/UriMemory.h @@ -5,43 +5,43 @@ * Copyright (C) 2018, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef URI_MEMORY_H -#define URI_MEMORY_H 1 - - - +#ifndef URI_MEMORY_H +#define URI_MEMORY_H 1 + + + #ifndef URI_DOXYGEN # include <uriparser/Uri.h> #endif @@ -59,20 +59,20 @@ -#ifdef __cplusplus -# define URIPARSER_EXTERN extern "C" -#else -# define URIPARSER_EXTERN extern -#endif - -URIPARSER_EXTERN UriMemoryManager defaultMemoryManager; - -#undef URIPARSER_EXTERN - - +#ifdef __cplusplus +# define URIPARSER_EXTERN extern "C" +#else +# define URIPARSER_EXTERN extern +#endif +URIPARSER_EXTERN UriMemoryManager defaultMemoryManager; + +#undef URIPARSER_EXTERN + + + UriBool uriMemoryManagerIsComplete(const UriMemoryManager * memory); - - - -#endif /* URI_MEMORY_H */ + + + +#endif /* URI_MEMORY_H */ diff --git a/contrib/restricted/uriparser/src/UriNormalize.c b/contrib/restricted/uriparser/src/UriNormalize.c index eb072b2f20..01d550684d 100644 --- a/contrib/restricted/uriparser/src/UriNormalize.c +++ b/contrib/restricted/uriparser/src/UriNormalize.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -86,7 +86,7 @@ static int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri, unsigned int inM static UriBool URI_FUNC(MakeRangeOwner)(unsigned int * doneMask, unsigned int maskTest, URI_TYPE(TextRange) * range, UriMemoryManager * memory); -static UriBool URI_FUNC(MakeOwnerEngine)(URI_TYPE(Uri) * uri, +static UriBool URI_FUNC(MakeOwnerEngine)(URI_TYPE(Uri) * uri, unsigned int * doneMask, UriMemoryManager * memory); static void URI_FUNC(FixPercentEncodingInplace)(const URI_CHAR * first, @@ -401,7 +401,7 @@ static URI_INLINE UriBool URI_FUNC(MakeRangeOwner)(unsigned int * doneMask, -static URI_INLINE UriBool URI_FUNC(MakeOwnerEngine)(URI_TYPE(Uri) * uri, +static URI_INLINE UriBool URI_FUNC(MakeOwnerEngine)(URI_TYPE(Uri) * uri, unsigned int * doneMask, UriMemoryManager * memory) { URI_TYPE(PathSegment) * walker = uri->pathHead; if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_SCHEME, @@ -763,7 +763,7 @@ static URI_INLINE int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri, /* Dup all not duped yet */ if ((outMask == NULL) && !uri->owner) { - if (!URI_FUNC(MakeOwnerEngine)(uri, &doneMask, memory)) { + if (!URI_FUNC(MakeOwnerEngine)(uri, &doneMask, memory)) { URI_FUNC(PreventLeakage)(uri, doneMask, memory); return URI_ERROR_MALLOC; } @@ -775,35 +775,35 @@ static URI_INLINE int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri, -int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) { - unsigned int doneMask = URI_NORMALIZED; - - URI_CHECK_MEMORY_MANAGER(memory); /* may return */ - - if (uri == NULL) { - return URI_ERROR_NULL; - } - - if (uri->owner == URI_TRUE) { - return URI_SUCCESS; - } - - if (! URI_FUNC(MakeOwnerEngine)(uri, &doneMask, memory)) { - URI_FUNC(PreventLeakage)(uri, doneMask, memory); - return URI_ERROR_MALLOC; - } - - uri->owner = URI_TRUE; - - return URI_SUCCESS; -} - - - -int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri) { - return URI_FUNC(MakeOwnerMm)(uri, NULL); -} - - - +int URI_FUNC(MakeOwnerMm)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) { + unsigned int doneMask = URI_NORMALIZED; + + URI_CHECK_MEMORY_MANAGER(memory); /* may return */ + + if (uri == NULL) { + return URI_ERROR_NULL; + } + + if (uri->owner == URI_TRUE) { + return URI_SUCCESS; + } + + if (! URI_FUNC(MakeOwnerEngine)(uri, &doneMask, memory)) { + URI_FUNC(PreventLeakage)(uri, doneMask, memory); + return URI_ERROR_MALLOC; + } + + uri->owner = URI_TRUE; + + return URI_SUCCESS; +} + + + +int URI_FUNC(MakeOwner)(URI_TYPE(Uri) * uri) { + return URI_FUNC(MakeOwnerMm)(uri, NULL); +} + + + #endif diff --git a/contrib/restricted/uriparser/src/UriNormalizeBase.c b/contrib/restricted/uriparser/src/UriNormalizeBase.c index a74fcd3f8b..ffe52355f4 100644 --- a/contrib/restricted/uriparser/src/UriNormalizeBase.c +++ b/contrib/restricted/uriparser/src/UriNormalizeBase.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriNormalizeBase.h b/contrib/restricted/uriparser/src/UriNormalizeBase.h index 8651c86166..58e6870f30 100644 --- a/contrib/restricted/uriparser/src/UriNormalizeBase.h +++ b/contrib/restricted/uriparser/src/UriNormalizeBase.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriParse.c b/contrib/restricted/uriparser/src/UriParse.c index eefa8d1347..25fee3ac51 100644 --- a/contrib/restricted/uriparser/src/UriParse.c +++ b/contrib/restricted/uriparser/src/UriParse.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriParseBase.c b/contrib/restricted/uriparser/src/UriParseBase.c index 3a4aa08f6b..fcdc867e0f 100644 --- a/contrib/restricted/uriparser/src/UriParseBase.c +++ b/contrib/restricted/uriparser/src/UriParseBase.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriParseBase.h b/contrib/restricted/uriparser/src/UriParseBase.h index 6d7379de1c..8a7d8d3c85 100644 --- a/contrib/restricted/uriparser/src/UriParseBase.h +++ b/contrib/restricted/uriparser/src/UriParseBase.h @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriQuery.c b/contrib/restricted/uriparser/src/UriQuery.c index b2734bc2c8..b7e14527c1 100644 --- a/contrib/restricted/uriparser/src/UriQuery.c +++ b/contrib/restricted/uriparser/src/UriQuery.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -110,7 +110,7 @@ int URI_FUNC(ComposeQueryCharsRequiredEx)(const URI_TYPE(QueryList) * queryList, int URI_FUNC(ComposeQuery)(URI_CHAR * dest, - const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten) { + const URI_TYPE(QueryList) * queryList, int maxChars, int * charsWritten) { const UriBool spaceToPlus = URI_TRUE; const UriBool normalizeBreaks = URI_TRUE; diff --git a/contrib/restricted/uriparser/src/UriRecompose.c b/contrib/restricted/uriparser/src/UriRecompose.c index 5027eca6cf..19adb2d085 100644 --- a/contrib/restricted/uriparser/src/UriRecompose.c +++ b/contrib/restricted/uriparser/src/UriRecompose.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriResolve.c b/contrib/restricted/uriparser/src/UriResolve.c index 80031a894d..25c5088b8f 100644 --- a/contrib/restricted/uriparser/src/UriResolve.c +++ b/contrib/restricted/uriparser/src/UriResolve.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/src/UriShorten.c b/contrib/restricted/uriparser/src/UriShorten.c index d2f893592d..88e1c65204 100644 --- a/contrib/restricted/uriparser/src/UriShorten.c +++ b/contrib/restricted/uriparser/src/UriShorten.c @@ -5,32 +5,32 @@ * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED diff --git a/contrib/restricted/uriparser/test/FourSuite.cpp b/contrib/restricted/uriparser/test/FourSuite.cpp index 466a94cb67..a06434613e 100644 --- a/contrib/restricted/uriparser/test/FourSuite.cpp +++ b/contrib/restricted/uriparser/test/FourSuite.cpp @@ -1,632 +1,632 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> - * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <gtest/gtest.h> - -#include <uriparser/Uri.h> - - - -// All testcases in this file are coming from -// http://cvs.4suite.org/viewcvs/4Suite/test/Lib/test_uri.py - - -namespace { - -bool testAddOrRemoveBaseHelper(const char * ref, const char * base, - const char * expected, bool add = true, bool domainRootMode = false) { - UriParserStateA stateA; - - // Base - UriUriA baseUri; - stateA.uri = &baseUri; - int res = uriParseUriA(&stateA, base); - if (res != 0) { - return false; - } - - // Rel - UriUriA relUri; - stateA.uri = &relUri; - res = uriParseUriA(&stateA, ref); - if (res != 0) { - uriFreeUriMembersA(&baseUri); - return false; - } - - // Expected result - UriUriA expectedUri; - stateA.uri = &expectedUri; - res = uriParseUriA(&stateA, expected); - if (res != 0) { - uriFreeUriMembersA(&baseUri); - uriFreeUriMembersA(&relUri); - uriFreeUriMembersA(&expectedUri); - return false; - } - - // Transform - UriUriA transformedUri; - if (add) { - res = uriAddBaseUriA(&transformedUri, &relUri, &baseUri); - } else { - res = uriRemoveBaseUriA(&transformedUri, &relUri, &baseUri, - domainRootMode ? URI_TRUE : URI_FALSE); - } - if (res != 0) { - uriFreeUriMembersA(&baseUri); - uriFreeUriMembersA(&relUri); - uriFreeUriMembersA(&expectedUri); - uriFreeUriMembersA(&transformedUri); - return false; - } - - const bool equal = (URI_TRUE == uriEqualsUriA(&transformedUri, &expectedUri)); - if (!equal) { - char transformedUriText[1024 * 8]; - char expectedUriText[1024 * 8]; - uriToStringA(transformedUriText, &transformedUri, 1024 * 8, NULL); - uriToStringA(expectedUriText, &expectedUri, 1024 * 8, NULL); - printf("\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", expectedUriText, transformedUriText); - } - - uriFreeUriMembersA(&baseUri); - uriFreeUriMembersA(&relUri); - uriFreeUriMembersA(&expectedUri); - uriFreeUriMembersA(&transformedUri); - return equal; -} - -} // namespace - - -TEST(FourSuite, AbsolutizeTestCases) { - const char * const BASE_URI[] = { - "http://a/b/c/d;p?q", - "http://a/b/c/d;p?q=1/2", - "http://a/b/c/d;p=1/2?q", - "fred:///s//a/b/c", - "http:///s//a/b/c"}; - - // ref, base, exptected - - // http://lists.w3.org/Archives/Public/uri/2004Feb/0114.html - ASSERT_TRUE(testAddOrRemoveBaseHelper("../c", "foo:a/b", "foo:c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("foo:.", "foo:a", "foo:")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/foo/../../../bar", "zz:abc", "zz:/bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/foo/../bar", "zz:abc", "zz:/bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("foo/../../../bar", "zz:abc", "zz:bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("foo/../bar", "zz:abc", "zz:bar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("zz:.", "zz:abc", "zz:")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/.", BASE_URI[0], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/.foo", BASE_URI[0], "http://a/.foo")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".foo", BASE_URI[0], "http://a/b/c/.foo")); - - // http://gbiv.com/protocols/uri/test/rel_examples1.html - // examples from RFC 2396 - ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[0], "g:h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[0], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[0], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[0], "http://a/b/c/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[0], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[0], "http://g")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[0], "http://a/b/c/d;p?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[0], "http://a/b/c/g?y")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("#s", BASE_URI[0], "http://a/b/c/d;p?q#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s", BASE_URI[0], "http://a/b/c/g#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y#s", BASE_URI[0], "http://a/b/c/g?y#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(";x", BASE_URI[0], "http://a/b/c/;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x", BASE_URI[0], "http://a/b/c/g;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x?y#s", BASE_URI[0], "http://a/b/c/g;x?y#s")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("", BASE_URI[0], "http://a/b/c/d;p?q")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".", BASE_URI[0], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[0], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("..", BASE_URI[0], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[0], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[0], "http://a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../..", BASE_URI[0], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[0], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[0], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[0], "http://a/g")); // http://a/../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[0], "http://a/g")); // http://a/../../g - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("/./g", BASE_URI[0], "http://a/g")); - - // changed with RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("/../g", BASE_URI[0], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g.", BASE_URI[0], "http://a/b/c/g.")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".g", BASE_URI[0], "http://a/b/c/.g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g..", BASE_URI[0], "http://a/b/c/g..")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("..g", BASE_URI[0], "http://a/b/c/..g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./../g", BASE_URI[0], "http://a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g/.", BASE_URI[0], "http://a/b/c/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/./h", BASE_URI[0], "http://a/b/c/g/h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/../h", BASE_URI[0], "http://a/b/c/h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/./y", BASE_URI[0], "http://a/b/c/g;x=1/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/../y", BASE_URI[0], "http://a/b/c/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/./x", BASE_URI[0], "http://a/b/c/g?y/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/../x", BASE_URI[0], "http://a/b/c/g?y/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/./x", BASE_URI[0], "http://a/b/c/g#s/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/../x", BASE_URI[0], "http://a/b/c/g#s/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:g", BASE_URI[0], "http:g")); // http://a/b/c/g - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:", BASE_URI[0], "http:")); // BASE_URI[0] - - // not sure where this one originated - ASSERT_TRUE(testAddOrRemoveBaseHelper("/a/b/c/./../../g", BASE_URI[0], "http://a/a/g")); - - // http://gbiv.com/protocols/uri/test/rel_examples2.html - // slashes in base URI's query args - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[1], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[1], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[1], "http://a/b/c/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[1], "http://a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[1], "http://g")); - - // changed in RFC 2396bis - // ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[1], "http://a/b/c/?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[1], "http://a/b/c/d;p?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[1], "http://a/b/c/g?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/./x", BASE_URI[1], "http://a/b/c/g?y/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/../x", BASE_URI[1], "http://a/b/c/g?y/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s", BASE_URI[1], "http://a/b/c/g#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/./x", BASE_URI[1], "http://a/b/c/g#s/./x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/../x", BASE_URI[1], "http://a/b/c/g#s/../x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[1], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[1], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[1], "http://a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[1], "http://a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[1], "http://a/g")); - - // http://gbiv.com/protocols/uri/test/rel_examples3.html - // slashes in path params - // all of these changed in RFC 2396bis - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[2], "http://a/b/c/d;p=1/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[2], "http://a/b/c/d;p=1/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[2], "http://a/b/c/d;p=1/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[2], "http://a/b/c/d;p=1/g?y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(";x", BASE_URI[2], "http://a/b/c/d;p=1/;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x", BASE_URI[2], "http://a/b/c/d;p=1/g;x")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/./y", BASE_URI[2], "http://a/b/c/d;p=1/g;x=1/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/../y", BASE_URI[2], "http://a/b/c/d;p=1/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[2], "http://a/b/c/d;p=1/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[2], "http://a/b/c/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[2], "http://a/b/c/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[2], "http://a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[2], "http://a/b/g")); - - // http://gbiv.com/protocols/uri/test/rel_examples4.html - // double and triple slash, unknown scheme - ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[3], "g:h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[3], "fred:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[3], "fred:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[3], "fred:///s//a/b/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[3], "fred:///g")); // may change to fred:///s//a/g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[3], "fred://g")); // may change to fred:///s//g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g/x", BASE_URI[3], "fred://g/x")); // may change to fred:///s//g/x - ASSERT_TRUE(testAddOrRemoveBaseHelper("///g", BASE_URI[3], "fred:///g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[3], "fred:///s//a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[3], "fred:///s//a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[3], "fred:///s//a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[3], "fred:///s//")); // may change to fred:///s//a/../ - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[3], "fred:///s//g")); // may change to fred:///s//a/../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[3], "fred:///s/g")); // may change to fred:///s//a/../../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[3], "fred:///g")); // may change to fred:///s//a/../../../g - - // http://gbiv.com/protocols/uri/test/rel_examples5.html - // double and triple slash, well-known scheme - ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[4], "g:h")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[4], "http:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[4], "http:///s//a/b/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[4], "http:///s//a/b/g/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[4], "http:///g")); // may change to http:///s//a/g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[4], "http://g")); // may change to http:///s//g - ASSERT_TRUE(testAddOrRemoveBaseHelper("//g/x", BASE_URI[4], "http://g/x")); // may change to http:///s//g/x - ASSERT_TRUE(testAddOrRemoveBaseHelper("///g", BASE_URI[4], "http:///g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[4], "http:///s//a/b/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[4], "http:///s//a/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[4], "http:///s//a/g")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[4], "http:///s//")); // may change to http:///s//a/../ - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[4], "http:///s//g")); // may change to http:///s//a/../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[4], "http:///s/g")); // may change to http:///s//a/../../g - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[4], "http:///g")); // may change to http:///s//a/../../../g - - // from Dan Connelly's tests in http://www.w3.org/2000/10/swap/uripath.py - ASSERT_TRUE(testAddOrRemoveBaseHelper("bar:abc", "foo:xyz", "bar:abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../abc", "http://example/x/y/z", "http://example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/x/abc", "http://example2/x/y/z", "http://example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../r", "http://ex/x/y/z", "http://ex/x/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r", "http://ex/x/y", "http://ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s", "http://ex/x/y", "http://ex/x/q/r#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s/t", "http://ex/x/y", "http://ex/x/q/r#s/t")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("ftp://ex/x/q/r", "http://ex/x/y", "ftp://ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y", "http://ex/x/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y/", "http://ex/x/y/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y/pdq", "http://ex/x/y/pdq")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("z/", "http://ex/x/y/", "http://ex/x/y/z/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("#Animal", "file:/swap/test/animal.rdf", "file:/swap/test/animal.rdf#Animal")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../abc", "file:/e/x/y/z", "file:/e/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/example/x/abc", "file:/example2/x/y/z", "file:/example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../r", "file:/ex/x/y/z", "file:/ex/x/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/r", "file:/ex/x/y/z", "file:/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r", "file:/ex/x/y", "file:/ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s", "file:/ex/x/y", "file:/ex/x/q/r#s")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#", "file:/ex/x/y", "file:/ex/x/q/r#")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s/t", "file:/ex/x/y", "file:/ex/x/q/r#s/t")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("ftp://ex/x/q/r", "file:/ex/x/y", "ftp://ex/x/q/r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y", "file:/ex/x/y")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y/", "file:/ex/x/y/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y/pdq", "file:/ex/x/y/pdq")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("z/", "file:/ex/x/y/", "file:/ex/x/y/z/")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("file://meetings.example.com/cal#m1", "file:/devel/WWW/2000/10/swap/test/reluri-1.n3", "file://meetings.example.com/cal#m1")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("file://meetings.example.com/cal#m1", "file:/home/connolly/w3ccvs/WWW/2000/10/swap/test/reluri-1.n3", "file://meetings.example.com/cal#m1")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./#blort", "file:/some/dir/foo", "file:/some/dir/#blort")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./#", "file:/some/dir/foo", "file:/some/dir/#")); - - // Ryan Lee - ASSERT_TRUE(testAddOrRemoveBaseHelper("./", "http://example/x/abc.efg", "http://example/x/")); - - // Graham Klyne's tests - // http://www.ninebynine.org/Software/HaskellUtils/Network/UriTest.xls - // 01-31 are from Connelly's cases - - // 32-49 - ASSERT_TRUE(testAddOrRemoveBaseHelper("./q:r", "http://ex/x/y", "http://ex/x/q:r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./p=q:r", "http://ex/x/y", "http://ex/x/p=q:r")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?pp/rr", "http://ex/x/y?pp/qq", "http://ex/x/y?pp/rr")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("y/z", "http://ex/x/y?pp/qq", "http://ex/x/y/z")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local/qual@domain.org#frag", "mailto:local", "mailto:local/qual@domain.org#frag")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("more/qual2@domain2.org#frag", "mailto:local/qual1@domain1.org", "mailto:local/more/qual2@domain2.org#frag")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("y?q", "http://ex/x/y?q", "http://ex/x/y?q")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x/y?q", "http://ex?p", "http://ex/x/y?q")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("c/d", "foo:a/b", "foo:a/c/d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/c/d", "foo:a/b", "foo:/c/d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("", "foo:a/b?c#d", "foo:a/b?c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("b/c", "foo:a", "foo:b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../b/c", "foo:/a/y/z", "foo:/a/b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("./b/c", "foo:a", "foo:b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/./b/c", "foo:a", "foo:/b/c")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../d", "foo://a//b/c", "foo://a/d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper(".", "foo:a", "foo:")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("..", "foo:a", "foo:")); - - // 50-57 (cf. TimBL comments -- - // http://lists.w3.org/Archives/Public/uri/2003Feb/0028.html, - // http://lists.w3.org/Archives/Public/uri/2003Jan/0008.html) - ASSERT_TRUE(testAddOrRemoveBaseHelper("abc", "http://example/x/y%2Fz", "http://example/x/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../../x%2Fabc", "http://example/a/x/y/z", "http://example/a/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../x%2Fabc", "http://example/a/x/y%2Fz", "http://example/a/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("abc", "http://example/x%2Fy/z", "http://example/x%2Fy/abc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("q%3Ar", "http://ex/x/y", "http://ex/x/q%3Ar")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y%2Fz", "http://example/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y/z", "http://example/x%2Fabc")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y%2Fz", "http://example/x%2Fabc")); - - // 70-77 - ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2", "mailto:local1@domain1?query1", "mailto:local2@domain2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2?query2", "mailto:local1@domain1", "mailto:local2@domain2?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2?query2", "mailto:local1@domain1?query1", "mailto:local2@domain2?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?query2", "mailto:local@domain?query1", "mailto:local@domain?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("local@domain?query2", "mailto:?query1", "mailto:local@domain?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("?query2", "mailto:local@domain?query1", "mailto:local@domain?query2")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/a/b?c/../d", "foo:bar", "http://example/a/b?c/../d")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/a/b#c/../d", "foo:bar", "http://example/a/b#c/../d")); - - // 82-88 - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:this", "http://example.org/base/uri", "http:this")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("http:this", "http:base", "http:this")); - // Whole in the URI spec, see http://lists.w3.org/Archives/Public/uri/2007Aug/0003.html - // ASSERT_TRUE(testAddOrRemoveBaseHelper(".//g", "f:/a", "f://g")); // ORIGINAL - ASSERT_TRUE(testAddOrRemoveBaseHelper(".//g", "f:/a", "f:/.//g")); // FIXED ONE - ASSERT_TRUE(testAddOrRemoveBaseHelper("b/c//d/e", "f://example.org/base/a", "f://example.org/base/b/c//d/e")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("m2@example.ord/c2@example.org", "mid:m@example.ord/c@example.org", "mid:m@example.ord/m2@example.ord/c2@example.org")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("mini1.xml", "file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/", "file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/mini1.xml")); - ASSERT_TRUE(testAddOrRemoveBaseHelper("../b/c", "foo:a/y/z", "foo:a/b/c")); -} - - - -TEST(FourSuite, RelativizeTestCases) { - const bool REMOVE_MODE = false; - const bool DOMAIN_ROOT_MODE = true; - - // to convert, base, exptected - - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/d", "b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/b/b/c", "s://ex/a/d", "/b/b/c", REMOVE_MODE, DOMAIN_ROOT_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/b/", "c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://other.ex/a/b/", "s://ex/a/d", "//other.ex/a/b/", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://other.ex/a/d", "//ex/a/b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("t://ex/a/b/c", "s://ex/a/d", "t://ex/a/b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "t://ex/a/d", "s://ex/a/b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a", "s://ex/b/c/d", "/a", REMOVE_MODE, DOMAIN_ROOT_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/b/c/d", "s://ex/a", "b/c/d", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c?h", "s://ex/a/d?w", "b/c?h", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c#h", "s://ex/a/d#w", "b/c#h", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c?h#i", "s://ex/a/d?w#j", "b/c?h#i", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a#i", "s://ex/a", "#i", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a?i", "s://ex/a", "?i", REMOVE_MODE)); - - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/", "s://ex/a/b/", "", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b", "s://ex/a/b", "", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/", "s://ex/", "", REMOVE_MODE)); - - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/d/c", "../b/c", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c/", "s://ex/a/d/c", "../b/c/", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c/d", "s://ex/a/d/c/d", "../../b/c/d", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/d/e/f", "/a/b/c", REMOVE_MODE, DOMAIN_ROOT_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/", "s://ex/a/c/d/e", "../../b/", REMOVE_MODE)); - - // Some tests to ensure that empty path segments don't cause problems. - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b", "s://ex/a//b/c", "../../b", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a///b", "s://ex/a/", ".///b", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/", "s://ex/a///b", "../../", REMOVE_MODE)); - ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a//b/c", "s://ex/a/b", ".//b/c", REMOVE_MODE)); -} - - -namespace { - -int testParseUri(const char * uriText, const char ** expectedErrorPos = NULL) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - int res = uriParseUriA(&state, uriText); - if (expectedErrorPos != NULL) { - *expectedErrorPos = state.errorPos; - } - uriFreeUriMembersA(&uri); - return res; -} - - - -bool testGoodUri(const char * uriText) { - return (testParseUri(uriText) == 0); -} - - - -bool testBadUri(const char * uriText, int expectedErrorOffset = -1) { - const char * errorPos = NULL; - const int ret = testParseUri(uriText, &errorPos); - return ((ret == URI_ERROR_SYNTAX) - && (errorPos != NULL) - && ( - (expectedErrorOffset == -1) - || (errorPos == (uriText + expectedErrorOffset)) - )); -} - -} // namespace - - - -TEST(FourSuite, GoodUriReferences) { - ASSERT_TRUE(testGoodUri("file:///foo/bar")); - ASSERT_TRUE(testGoodUri("mailto:user@host?subject=blah")); - ASSERT_TRUE(testGoodUri("dav:")); // empty opaque part / rel-path allowed by RFC 2396bis - ASSERT_TRUE(testGoodUri("about:")); // empty opaque part / rel-path allowed by RFC 2396bis - - // the following test cases are from a Perl script by David A. Wheeler - // at http://www.dwheeler.com/secure-programs/url.pl - ASSERT_TRUE(testGoodUri("http://www.yahoo.com")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/")); - ASSERT_TRUE(testGoodUri("http://1.2.3.4/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/stuff")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/stuff/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello%20world/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi+wan&status=jedi")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?onery")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com#bottom")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/yelp.html#bottom")); - ASSERT_TRUE(testGoodUri("https://www.yahoo.com/")); - ASSERT_TRUE(testGoodUri("ftp://www.yahoo.com/")); - ASSERT_TRUE(testGoodUri("ftp://www.yahoo.com/hello")); - ASSERT_TRUE(testGoodUri("demo.txt")); - ASSERT_TRUE(testGoodUri("demo/hello.txt")); - ASSERT_TRUE(testGoodUri("demo/hello.txt?query=hello#fragment")); - ASSERT_TRUE(testGoodUri("/cgi-bin/query?query=hello#fragment")); - ASSERT_TRUE(testGoodUri("/demo.txt")); - ASSERT_TRUE(testGoodUri("/hello/demo.txt")); - ASSERT_TRUE(testGoodUri("hello/demo.txt")); - ASSERT_TRUE(testGoodUri("/")); - ASSERT_TRUE(testGoodUri("")); - ASSERT_TRUE(testGoodUri("#")); - ASSERT_TRUE(testGoodUri("#here")); - - // Wheeler's script says these are invalid, but they aren't - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=%00%01")); - ASSERT_TRUE(testGoodUri("http://www.yaho%6f.com")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello%00world/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello+world/")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi&")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi&type=")); - ASSERT_TRUE(testGoodUri("http://www.yahoo.com/yelp.html#")); - ASSERT_TRUE(testGoodUri("//")); - - // the following test cases are from a Haskell program by Graham Klyne - // at http://www.ninebynine.org/Software/HaskellUtils/Network/URITest.hs - ASSERT_TRUE(testGoodUri("http://example.org/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("mailto:local@domain.org")); - ASSERT_TRUE(testGoodUri("mailto:local@domain.org#frag")); - ASSERT_TRUE(testGoodUri("HTTP://EXAMPLE.ORG/AAA/BBB#CCC")); - ASSERT_TRUE(testGoodUri("//example.org/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("bbb#ccc")); - ASSERT_TRUE(testGoodUri("#ccc")); - ASSERT_TRUE(testGoodUri("#")); - ASSERT_TRUE(testGoodUri("A'C")); - - // escapes - ASSERT_TRUE(testGoodUri("http://example.org/aaa%2fbbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.org/aaa%2Fbbb#ccc")); - ASSERT_TRUE(testGoodUri("%2F")); - ASSERT_TRUE(testGoodUri("aaa%2Fbbb")); - - // ports - ASSERT_TRUE(testGoodUri("http://example.org:80/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.org:/aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.org./aaa/bbb#ccc")); - ASSERT_TRUE(testGoodUri("http://example.123./aaa/bbb#ccc")); - - // bare authority - ASSERT_TRUE(testGoodUri("http://example.org")); - - // IPv6 literals (from RFC2732): - ASSERT_TRUE(testGoodUri("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html")); - ASSERT_TRUE(testGoodUri("http://[1080:0:0:0:8:800:200C:417A]/index.html")); - ASSERT_TRUE(testGoodUri("http://[3ffe:2a00:100:7031::1]")); - ASSERT_TRUE(testGoodUri("http://[1080::8:800:200C:417A]/foo")); - ASSERT_TRUE(testGoodUri("http://[::192.9.5.5]/ipng")); - ASSERT_TRUE(testGoodUri("http://[::FFFF:129.144.52.38]:80/index.html")); - ASSERT_TRUE(testGoodUri("http://[2010:836B:4179::836B:4179]")); - ASSERT_TRUE(testGoodUri("//[2010:836B:4179::836B:4179]")); - - // Random other things that crop up - ASSERT_TRUE(testGoodUri("http://example/Andrȷ")); - ASSERT_TRUE(testGoodUri("file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/")); -} - - - -TEST(FourSuite, BadUriReferences) { - ASSERT_TRUE(testBadUri("beepbeep\x07\x07", 8)); - ASSERT_TRUE(testBadUri("\n", 0)); - ASSERT_TRUE(testBadUri("::", 0)); // not OK, per Roy Fielding on the W3C uri list on 2004-04-01 - - // the following test cases are from a Perl script by David A. Wheeler - // at http://www.dwheeler.com/secure-programs/url.pl - ASSERT_TRUE(testBadUri("http://www yahoo.com", 10)); - ASSERT_TRUE(testBadUri("http://www.yahoo.com/hello world/", 26)); - ASSERT_TRUE(testBadUri("http://www.yahoo.com/yelp.html#\"", 31)); - - // the following test cases are from a Haskell program by Graham Klyne - // at http://www.ninebynine.org/Software/HaskellUtils/Network/URITest.hs - ASSERT_TRUE(testBadUri("[2010:836B:4179::836B:4179]", 0)); - ASSERT_TRUE(testBadUri(" ", 0)); - ASSERT_TRUE(testBadUri("%", 1)); - ASSERT_TRUE(testBadUri("A%Z", 2)); - ASSERT_TRUE(testBadUri("%ZZ", 1)); - ASSERT_TRUE(testBadUri("%AZ", 2)); - ASSERT_TRUE(testBadUri("A C", 1)); - ASSERT_TRUE(testBadUri("A\\'C", 1)); // r"A\'C" - ASSERT_TRUE(testBadUri("A`C", 1)); - ASSERT_TRUE(testBadUri("A<C", 1)); - ASSERT_TRUE(testBadUri("A>C", 1)); - ASSERT_TRUE(testBadUri("A^C", 1)); - ASSERT_TRUE(testBadUri("A\\\\C", 1)); // r'A\\C' - ASSERT_TRUE(testBadUri("A{C", 1)); - ASSERT_TRUE(testBadUri("A|C", 1)); - ASSERT_TRUE(testBadUri("A}C", 1)); - ASSERT_TRUE(testBadUri("A[C", 1)); - ASSERT_TRUE(testBadUri("A]C", 1)); - ASSERT_TRUE(testBadUri("A[**]C", 1)); - ASSERT_TRUE(testBadUri("http://[xyz]/", 8)); - ASSERT_TRUE(testBadUri("http://]/", 7)); - ASSERT_TRUE(testBadUri("http://example.org/[2010:836B:4179::836B:4179]", 19)); - ASSERT_TRUE(testBadUri("http://example.org/abc#[2010:836B:4179::836B:4179]", 23)); - ASSERT_TRUE(testBadUri("http://example.org/xxx/[qwerty]#a[b]", 23)); - - // from a post to the W3C uri list on 2004-02-17 - // breaks at 22 instead of 17 because everything up to that point is a valid userinfo - ASSERT_TRUE(testBadUri("http://w3c.org:80path1/path2", 22)); -} - - - -namespace { - -bool normalizeAndCompare(const char * uriText, - const char * expectedNormalized) { - UriParserStateA stateA; - int res; - - UriUriA testUri; - stateA.uri = &testUri; - res = uriParseUriA(&stateA, uriText); - if (res != 0) { - uriFreeUriMembersA(&testUri); - return false; - } - - // Expected result - UriUriA expectedUri; - stateA.uri = &expectedUri; - res = uriParseUriA(&stateA, expectedNormalized); - if (res != 0) { - uriFreeUriMembersA(&testUri); - uriFreeUriMembersA(&expectedUri); - return false; - } - - res = uriNormalizeSyntaxA(&testUri); - if (res != 0) { - uriFreeUriMembersA(&testUri); - uriFreeUriMembersA(&expectedUri); - return false; - } - - const bool equalAfter = (URI_TRUE == uriEqualsUriA(&testUri, &expectedUri)); - uriFreeUriMembersA(&testUri); - uriFreeUriMembersA(&expectedUri); - return equalAfter; -} - -} // namespace - - - -TEST(FourSuite, CaseNormalizationTests) { - ASSERT_TRUE(normalizeAndCompare("HTTP://www.EXAMPLE.com/", "http://www.example.com/")); - ASSERT_TRUE(normalizeAndCompare("example://A/b/c/%7bfoo%7d", "example://a/b/c/%7Bfoo%7D")); -} - - - -TEST(FourSuite, PctEncNormalizationTests) { - ASSERT_TRUE(normalizeAndCompare("http://host/%7Euser/x/y/z", "http://host/~user/x/y/z")); - ASSERT_TRUE(normalizeAndCompare("http://host/%7euser/x/y/z", "http://host/~user/x/y/z")); -} - - - -TEST(FourSuite, PathSegmentNormalizationTests) { - ASSERT_TRUE(normalizeAndCompare("/a/b/../../c", "/c")); - // ASSERT_TRUE(normalizeAndCompare("a/b/../../c", "a/b/../../c")); - // Fixed: - ASSERT_TRUE(normalizeAndCompare("a/b/../../c", "c")); - ASSERT_TRUE(normalizeAndCompare("/a/b/././c", "/a/b/c")); - // ASSERT_TRUE(normalizeAndCompare("a/b/././c", "a/b/././c")); - // Fixed: - ASSERT_TRUE(normalizeAndCompare("a/b/././c", "a/b/c")); - ASSERT_TRUE(normalizeAndCompare("/a/b/../c/././d", "/a/c/d")); - // ASSERT_TRUE(normalizeAndCompare("a/b/../c/././d", "a/b/../c/././d")); - // Fixed: - ASSERT_TRUE(normalizeAndCompare("a/b/../c/././d", "a/c/d")); -} +/* + * uriparser - RFC 3986 URI parsing library + * + * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> + * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <gtest/gtest.h> + +#include <uriparser/Uri.h> + + + +// All testcases in this file are coming from +// http://cvs.4suite.org/viewcvs/4Suite/test/Lib/test_uri.py + + +namespace { + +bool testAddOrRemoveBaseHelper(const char * ref, const char * base, + const char * expected, bool add = true, bool domainRootMode = false) { + UriParserStateA stateA; + + // Base + UriUriA baseUri; + stateA.uri = &baseUri; + int res = uriParseUriA(&stateA, base); + if (res != 0) { + return false; + } + + // Rel + UriUriA relUri; + stateA.uri = &relUri; + res = uriParseUriA(&stateA, ref); + if (res != 0) { + uriFreeUriMembersA(&baseUri); + return false; + } + + // Expected result + UriUriA expectedUri; + stateA.uri = &expectedUri; + res = uriParseUriA(&stateA, expected); + if (res != 0) { + uriFreeUriMembersA(&baseUri); + uriFreeUriMembersA(&relUri); + uriFreeUriMembersA(&expectedUri); + return false; + } + + // Transform + UriUriA transformedUri; + if (add) { + res = uriAddBaseUriA(&transformedUri, &relUri, &baseUri); + } else { + res = uriRemoveBaseUriA(&transformedUri, &relUri, &baseUri, + domainRootMode ? URI_TRUE : URI_FALSE); + } + if (res != 0) { + uriFreeUriMembersA(&baseUri); + uriFreeUriMembersA(&relUri); + uriFreeUriMembersA(&expectedUri); + uriFreeUriMembersA(&transformedUri); + return false; + } + + const bool equal = (URI_TRUE == uriEqualsUriA(&transformedUri, &expectedUri)); + if (!equal) { + char transformedUriText[1024 * 8]; + char expectedUriText[1024 * 8]; + uriToStringA(transformedUriText, &transformedUri, 1024 * 8, NULL); + uriToStringA(expectedUriText, &expectedUri, 1024 * 8, NULL); + printf("\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", expectedUriText, transformedUriText); + } + + uriFreeUriMembersA(&baseUri); + uriFreeUriMembersA(&relUri); + uriFreeUriMembersA(&expectedUri); + uriFreeUriMembersA(&transformedUri); + return equal; +} + +} // namespace + + +TEST(FourSuite, AbsolutizeTestCases) { + const char * const BASE_URI[] = { + "http://a/b/c/d;p?q", + "http://a/b/c/d;p?q=1/2", + "http://a/b/c/d;p=1/2?q", + "fred:///s//a/b/c", + "http:///s//a/b/c"}; + + // ref, base, exptected + + // http://lists.w3.org/Archives/Public/uri/2004Feb/0114.html + ASSERT_TRUE(testAddOrRemoveBaseHelper("../c", "foo:a/b", "foo:c")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("foo:.", "foo:a", "foo:")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/foo/../../../bar", "zz:abc", "zz:/bar")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/foo/../bar", "zz:abc", "zz:/bar")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("foo/../../../bar", "zz:abc", "zz:bar")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("foo/../bar", "zz:abc", "zz:bar")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("zz:.", "zz:abc", "zz:")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/.", BASE_URI[0], "http://a/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/.foo", BASE_URI[0], "http://a/.foo")); + ASSERT_TRUE(testAddOrRemoveBaseHelper(".foo", BASE_URI[0], "http://a/b/c/.foo")); + + // http://gbiv.com/protocols/uri/test/rel_examples1.html + // examples from RFC 2396 + ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[0], "g:h")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[0], "http://a/b/c/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[0], "http://a/b/c/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[0], "http://a/b/c/g/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[0], "http://a/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[0], "http://g")); + + // changed with RFC 2396bis + ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[0], "http://a/b/c/d;p?y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[0], "http://a/b/c/g?y")); + + // changed with RFC 2396bis + ASSERT_TRUE(testAddOrRemoveBaseHelper("#s", BASE_URI[0], "http://a/b/c/d;p?q#s")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s", BASE_URI[0], "http://a/b/c/g#s")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y#s", BASE_URI[0], "http://a/b/c/g?y#s")); + ASSERT_TRUE(testAddOrRemoveBaseHelper(";x", BASE_URI[0], "http://a/b/c/;x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x", BASE_URI[0], "http://a/b/c/g;x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x?y#s", BASE_URI[0], "http://a/b/c/g;x?y#s")); + + // changed with RFC 2396bis + ASSERT_TRUE(testAddOrRemoveBaseHelper("", BASE_URI[0], "http://a/b/c/d;p?q")); + ASSERT_TRUE(testAddOrRemoveBaseHelper(".", BASE_URI[0], "http://a/b/c/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[0], "http://a/b/c/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("..", BASE_URI[0], "http://a/b/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[0], "http://a/b/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[0], "http://a/b/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../..", BASE_URI[0], "http://a/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[0], "http://a/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[0], "http://a/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[0], "http://a/g")); // http://a/../g + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[0], "http://a/g")); // http://a/../../g + + // changed with RFC 2396bis + ASSERT_TRUE(testAddOrRemoveBaseHelper("/./g", BASE_URI[0], "http://a/g")); + + // changed with RFC 2396bis + ASSERT_TRUE(testAddOrRemoveBaseHelper("/../g", BASE_URI[0], "http://a/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g.", BASE_URI[0], "http://a/b/c/g.")); + ASSERT_TRUE(testAddOrRemoveBaseHelper(".g", BASE_URI[0], "http://a/b/c/.g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g..", BASE_URI[0], "http://a/b/c/g..")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("..g", BASE_URI[0], "http://a/b/c/..g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./../g", BASE_URI[0], "http://a/b/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./g/.", BASE_URI[0], "http://a/b/c/g/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g/./h", BASE_URI[0], "http://a/b/c/g/h")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g/../h", BASE_URI[0], "http://a/b/c/h")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/./y", BASE_URI[0], "http://a/b/c/g;x=1/y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/../y", BASE_URI[0], "http://a/b/c/y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/./x", BASE_URI[0], "http://a/b/c/g?y/./x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/../x", BASE_URI[0], "http://a/b/c/g?y/../x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/./x", BASE_URI[0], "http://a/b/c/g#s/./x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/../x", BASE_URI[0], "http://a/b/c/g#s/../x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("http:g", BASE_URI[0], "http:g")); // http://a/b/c/g + ASSERT_TRUE(testAddOrRemoveBaseHelper("http:", BASE_URI[0], "http:")); // BASE_URI[0] + + // not sure where this one originated + ASSERT_TRUE(testAddOrRemoveBaseHelper("/a/b/c/./../../g", BASE_URI[0], "http://a/a/g")); + + // http://gbiv.com/protocols/uri/test/rel_examples2.html + // slashes in base URI's query args + ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[1], "http://a/b/c/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[1], "http://a/b/c/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[1], "http://a/b/c/g/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[1], "http://a/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[1], "http://g")); + + // changed in RFC 2396bis + // ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[1], "http://a/b/c/?y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("?y", BASE_URI[1], "http://a/b/c/d;p?y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[1], "http://a/b/c/g?y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/./x", BASE_URI[1], "http://a/b/c/g?y/./x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y/../x", BASE_URI[1], "http://a/b/c/g?y/../x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s", BASE_URI[1], "http://a/b/c/g#s")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/./x", BASE_URI[1], "http://a/b/c/g#s/./x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g#s/../x", BASE_URI[1], "http://a/b/c/g#s/../x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[1], "http://a/b/c/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[1], "http://a/b/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[1], "http://a/b/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[1], "http://a/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[1], "http://a/g")); + + // http://gbiv.com/protocols/uri/test/rel_examples3.html + // slashes in path params + // all of these changed in RFC 2396bis + ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[2], "http://a/b/c/d;p=1/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[2], "http://a/b/c/d;p=1/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[2], "http://a/b/c/d;p=1/g/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g?y", BASE_URI[2], "http://a/b/c/d;p=1/g?y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper(";x", BASE_URI[2], "http://a/b/c/d;p=1/;x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x", BASE_URI[2], "http://a/b/c/d;p=1/g;x")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/./y", BASE_URI[2], "http://a/b/c/d;p=1/g;x=1/y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g;x=1/../y", BASE_URI[2], "http://a/b/c/d;p=1/y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[2], "http://a/b/c/d;p=1/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[2], "http://a/b/c/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[2], "http://a/b/c/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[2], "http://a/b/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[2], "http://a/b/g")); + + // http://gbiv.com/protocols/uri/test/rel_examples4.html + // double and triple slash, unknown scheme + ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[3], "g:h")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[3], "fred:///s//a/b/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[3], "fred:///s//a/b/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[3], "fred:///s//a/b/g/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[3], "fred:///g")); // may change to fred:///s//a/g + ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[3], "fred://g")); // may change to fred:///s//g + ASSERT_TRUE(testAddOrRemoveBaseHelper("//g/x", BASE_URI[3], "fred://g/x")); // may change to fred:///s//g/x + ASSERT_TRUE(testAddOrRemoveBaseHelper("///g", BASE_URI[3], "fred:///g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[3], "fred:///s//a/b/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[3], "fred:///s//a/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[3], "fred:///s//a/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[3], "fred:///s//")); // may change to fred:///s//a/../ + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[3], "fred:///s//g")); // may change to fred:///s//a/../g + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[3], "fred:///s/g")); // may change to fred:///s//a/../../g + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[3], "fred:///g")); // may change to fred:///s//a/../../../g + + // http://gbiv.com/protocols/uri/test/rel_examples5.html + // double and triple slash, well-known scheme + ASSERT_TRUE(testAddOrRemoveBaseHelper("g:h", BASE_URI[4], "g:h")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g", BASE_URI[4], "http:///s//a/b/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./g", BASE_URI[4], "http:///s//a/b/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("g/", BASE_URI[4], "http:///s//a/b/g/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/g", BASE_URI[4], "http:///g")); // may change to http:///s//a/g + ASSERT_TRUE(testAddOrRemoveBaseHelper("//g", BASE_URI[4], "http://g")); // may change to http:///s//g + ASSERT_TRUE(testAddOrRemoveBaseHelper("//g/x", BASE_URI[4], "http://g/x")); // may change to http:///s//g/x + ASSERT_TRUE(testAddOrRemoveBaseHelper("///g", BASE_URI[4], "http:///g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./", BASE_URI[4], "http:///s//a/b/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../", BASE_URI[4], "http:///s//a/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../g", BASE_URI[4], "http:///s//a/g")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../", BASE_URI[4], "http:///s//")); // may change to http:///s//a/../ + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../g", BASE_URI[4], "http:///s//g")); // may change to http:///s//a/../g + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../g", BASE_URI[4], "http:///s/g")); // may change to http:///s//a/../../g + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../../../g", BASE_URI[4], "http:///g")); // may change to http:///s//a/../../../g + + // from Dan Connelly's tests in http://www.w3.org/2000/10/swap/uripath.py + ASSERT_TRUE(testAddOrRemoveBaseHelper("bar:abc", "foo:xyz", "bar:abc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../abc", "http://example/x/y/z", "http://example/x/abc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/x/abc", "http://example2/x/y/z", "http://example/x/abc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../r", "http://ex/x/y/z", "http://ex/x/r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r", "http://ex/x/y", "http://ex/x/q/r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s", "http://ex/x/y", "http://ex/x/q/r#s")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s/t", "http://ex/x/y", "http://ex/x/q/r#s/t")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("ftp://ex/x/q/r", "http://ex/x/y", "ftp://ex/x/q/r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y", "http://ex/x/y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y/", "http://ex/x/y/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("", "http://ex/x/y/pdq", "http://ex/x/y/pdq")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("z/", "http://ex/x/y/", "http://ex/x/y/z/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("#Animal", "file:/swap/test/animal.rdf", "file:/swap/test/animal.rdf#Animal")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../abc", "file:/e/x/y/z", "file:/e/x/abc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/example/x/abc", "file:/example2/x/y/z", "file:/example/x/abc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../r", "file:/ex/x/y/z", "file:/ex/x/r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/r", "file:/ex/x/y/z", "file:/r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r", "file:/ex/x/y", "file:/ex/x/q/r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s", "file:/ex/x/y", "file:/ex/x/q/r#s")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#", "file:/ex/x/y", "file:/ex/x/q/r#")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q/r#s/t", "file:/ex/x/y", "file:/ex/x/q/r#s/t")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("ftp://ex/x/q/r", "file:/ex/x/y", "ftp://ex/x/q/r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y", "file:/ex/x/y")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y/", "file:/ex/x/y/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("", "file:/ex/x/y/pdq", "file:/ex/x/y/pdq")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("z/", "file:/ex/x/y/", "file:/ex/x/y/z/")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("file://meetings.example.com/cal#m1", "file:/devel/WWW/2000/10/swap/test/reluri-1.n3", "file://meetings.example.com/cal#m1")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("file://meetings.example.com/cal#m1", "file:/home/connolly/w3ccvs/WWW/2000/10/swap/test/reluri-1.n3", "file://meetings.example.com/cal#m1")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./#blort", "file:/some/dir/foo", "file:/some/dir/#blort")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./#", "file:/some/dir/foo", "file:/some/dir/#")); + + // Ryan Lee + ASSERT_TRUE(testAddOrRemoveBaseHelper("./", "http://example/x/abc.efg", "http://example/x/")); + + // Graham Klyne's tests + // http://www.ninebynine.org/Software/HaskellUtils/Network/UriTest.xls + // 01-31 are from Connelly's cases + + // 32-49 + ASSERT_TRUE(testAddOrRemoveBaseHelper("./q:r", "http://ex/x/y", "http://ex/x/q:r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./p=q:r", "http://ex/x/y", "http://ex/x/p=q:r")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("?pp/rr", "http://ex/x/y?pp/qq", "http://ex/x/y?pp/rr")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("y/z", "http://ex/x/y?pp/qq", "http://ex/x/y/z")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("local/qual@domain.org#frag", "mailto:local", "mailto:local/qual@domain.org#frag")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("more/qual2@domain2.org#frag", "mailto:local/qual1@domain1.org", "mailto:local/more/qual2@domain2.org#frag")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("y?q", "http://ex/x/y?q", "http://ex/x/y?q")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/x/y?q", "http://ex?p", "http://ex/x/y?q")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("c/d", "foo:a/b", "foo:a/c/d")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/c/d", "foo:a/b", "foo:/c/d")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("", "foo:a/b?c#d", "foo:a/b?c")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("b/c", "foo:a", "foo:b/c")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../b/c", "foo:/a/y/z", "foo:/a/b/c")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("./b/c", "foo:a", "foo:b/c")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/./b/c", "foo:a", "foo:/b/c")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../d", "foo://a//b/c", "foo://a/d")); + ASSERT_TRUE(testAddOrRemoveBaseHelper(".", "foo:a", "foo:")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("..", "foo:a", "foo:")); + + // 50-57 (cf. TimBL comments -- + // http://lists.w3.org/Archives/Public/uri/2003Feb/0028.html, + // http://lists.w3.org/Archives/Public/uri/2003Jan/0008.html) + ASSERT_TRUE(testAddOrRemoveBaseHelper("abc", "http://example/x/y%2Fz", "http://example/x/abc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../../x%2Fabc", "http://example/a/x/y/z", "http://example/a/x%2Fabc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../x%2Fabc", "http://example/a/x/y%2Fz", "http://example/a/x%2Fabc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("abc", "http://example/x%2Fy/z", "http://example/x%2Fy/abc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("q%3Ar", "http://ex/x/y", "http://ex/x/q%3Ar")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y%2Fz", "http://example/x%2Fabc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y/z", "http://example/x%2Fabc")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("/x%2Fabc", "http://example/x/y%2Fz", "http://example/x%2Fabc")); + + // 70-77 + ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2", "mailto:local1@domain1?query1", "mailto:local2@domain2")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2?query2", "mailto:local1@domain1", "mailto:local2@domain2?query2")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("local2@domain2?query2", "mailto:local1@domain1?query1", "mailto:local2@domain2?query2")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("?query2", "mailto:local@domain?query1", "mailto:local@domain?query2")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("local@domain?query2", "mailto:?query1", "mailto:local@domain?query2")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("?query2", "mailto:local@domain?query1", "mailto:local@domain?query2")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/a/b?c/../d", "foo:bar", "http://example/a/b?c/../d")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("http://example/a/b#c/../d", "foo:bar", "http://example/a/b#c/../d")); + + // 82-88 + ASSERT_TRUE(testAddOrRemoveBaseHelper("http:this", "http://example.org/base/uri", "http:this")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("http:this", "http:base", "http:this")); + // Whole in the URI spec, see http://lists.w3.org/Archives/Public/uri/2007Aug/0003.html + // ASSERT_TRUE(testAddOrRemoveBaseHelper(".//g", "f:/a", "f://g")); // ORIGINAL + ASSERT_TRUE(testAddOrRemoveBaseHelper(".//g", "f:/a", "f:/.//g")); // FIXED ONE + ASSERT_TRUE(testAddOrRemoveBaseHelper("b/c//d/e", "f://example.org/base/a", "f://example.org/base/b/c//d/e")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("m2@example.ord/c2@example.org", "mid:m@example.ord/c@example.org", "mid:m@example.ord/m2@example.ord/c2@example.org")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("mini1.xml", "file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/", "file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/mini1.xml")); + ASSERT_TRUE(testAddOrRemoveBaseHelper("../b/c", "foo:a/y/z", "foo:a/b/c")); +} + + + +TEST(FourSuite, RelativizeTestCases) { + const bool REMOVE_MODE = false; + const bool DOMAIN_ROOT_MODE = true; + + // to convert, base, exptected + + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/d", "b/c", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/b/b/c", "s://ex/a/d", "/b/b/c", REMOVE_MODE, DOMAIN_ROOT_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/b/", "c", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://other.ex/a/b/", "s://ex/a/d", "//other.ex/a/b/", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://other.ex/a/d", "//ex/a/b/c", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("t://ex/a/b/c", "s://ex/a/d", "t://ex/a/b/c", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "t://ex/a/d", "s://ex/a/b/c", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a", "s://ex/b/c/d", "/a", REMOVE_MODE, DOMAIN_ROOT_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/b/c/d", "s://ex/a", "b/c/d", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c?h", "s://ex/a/d?w", "b/c?h", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c#h", "s://ex/a/d#w", "b/c#h", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c?h#i", "s://ex/a/d?w#j", "b/c?h#i", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a#i", "s://ex/a", "#i", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a?i", "s://ex/a", "?i", REMOVE_MODE)); + + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/", "s://ex/a/b/", "", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b", "s://ex/a/b", "", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/", "s://ex/", "", REMOVE_MODE)); + + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/a/d/c", "../b/c", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c/", "s://ex/a/d/c", "../b/c/", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c/d", "s://ex/a/d/c/d", "../../b/c/d", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/c", "s://ex/d/e/f", "/a/b/c", REMOVE_MODE, DOMAIN_ROOT_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b/", "s://ex/a/c/d/e", "../../b/", REMOVE_MODE)); + + // Some tests to ensure that empty path segments don't cause problems. + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/b", "s://ex/a//b/c", "../../b", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a///b", "s://ex/a/", ".///b", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a/", "s://ex/a///b", "../../", REMOVE_MODE)); + ASSERT_TRUE(testAddOrRemoveBaseHelper("s://ex/a//b/c", "s://ex/a/b", ".//b/c", REMOVE_MODE)); +} + + +namespace { + +int testParseUri(const char * uriText, const char ** expectedErrorPos = NULL) { + UriParserStateA state; + UriUriA uri; + state.uri = &uri; + int res = uriParseUriA(&state, uriText); + if (expectedErrorPos != NULL) { + *expectedErrorPos = state.errorPos; + } + uriFreeUriMembersA(&uri); + return res; +} + + + +bool testGoodUri(const char * uriText) { + return (testParseUri(uriText) == 0); +} + + + +bool testBadUri(const char * uriText, int expectedErrorOffset = -1) { + const char * errorPos = NULL; + const int ret = testParseUri(uriText, &errorPos); + return ((ret == URI_ERROR_SYNTAX) + && (errorPos != NULL) + && ( + (expectedErrorOffset == -1) + || (errorPos == (uriText + expectedErrorOffset)) + )); +} + +} // namespace + + + +TEST(FourSuite, GoodUriReferences) { + ASSERT_TRUE(testGoodUri("file:///foo/bar")); + ASSERT_TRUE(testGoodUri("mailto:user@host?subject=blah")); + ASSERT_TRUE(testGoodUri("dav:")); // empty opaque part / rel-path allowed by RFC 2396bis + ASSERT_TRUE(testGoodUri("about:")); // empty opaque part / rel-path allowed by RFC 2396bis + + // the following test cases are from a Perl script by David A. Wheeler + // at http://www.dwheeler.com/secure-programs/url.pl + ASSERT_TRUE(testGoodUri("http://www.yahoo.com")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/")); + ASSERT_TRUE(testGoodUri("http://1.2.3.4/")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/stuff")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/stuff/")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello%20world/")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi+wan&status=jedi")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com?onery")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com#bottom")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/yelp.html#bottom")); + ASSERT_TRUE(testGoodUri("https://www.yahoo.com/")); + ASSERT_TRUE(testGoodUri("ftp://www.yahoo.com/")); + ASSERT_TRUE(testGoodUri("ftp://www.yahoo.com/hello")); + ASSERT_TRUE(testGoodUri("demo.txt")); + ASSERT_TRUE(testGoodUri("demo/hello.txt")); + ASSERT_TRUE(testGoodUri("demo/hello.txt?query=hello#fragment")); + ASSERT_TRUE(testGoodUri("/cgi-bin/query?query=hello#fragment")); + ASSERT_TRUE(testGoodUri("/demo.txt")); + ASSERT_TRUE(testGoodUri("/hello/demo.txt")); + ASSERT_TRUE(testGoodUri("hello/demo.txt")); + ASSERT_TRUE(testGoodUri("/")); + ASSERT_TRUE(testGoodUri("")); + ASSERT_TRUE(testGoodUri("#")); + ASSERT_TRUE(testGoodUri("#here")); + + // Wheeler's script says these are invalid, but they aren't + ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=%00%01")); + ASSERT_TRUE(testGoodUri("http://www.yaho%6f.com")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello%00world/")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/hello+world/")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi&")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com?name=obi&type=")); + ASSERT_TRUE(testGoodUri("http://www.yahoo.com/yelp.html#")); + ASSERT_TRUE(testGoodUri("//")); + + // the following test cases are from a Haskell program by Graham Klyne + // at http://www.ninebynine.org/Software/HaskellUtils/Network/URITest.hs + ASSERT_TRUE(testGoodUri("http://example.org/aaa/bbb#ccc")); + ASSERT_TRUE(testGoodUri("mailto:local@domain.org")); + ASSERT_TRUE(testGoodUri("mailto:local@domain.org#frag")); + ASSERT_TRUE(testGoodUri("HTTP://EXAMPLE.ORG/AAA/BBB#CCC")); + ASSERT_TRUE(testGoodUri("//example.org/aaa/bbb#ccc")); + ASSERT_TRUE(testGoodUri("/aaa/bbb#ccc")); + ASSERT_TRUE(testGoodUri("bbb#ccc")); + ASSERT_TRUE(testGoodUri("#ccc")); + ASSERT_TRUE(testGoodUri("#")); + ASSERT_TRUE(testGoodUri("A'C")); + + // escapes + ASSERT_TRUE(testGoodUri("http://example.org/aaa%2fbbb#ccc")); + ASSERT_TRUE(testGoodUri("http://example.org/aaa%2Fbbb#ccc")); + ASSERT_TRUE(testGoodUri("%2F")); + ASSERT_TRUE(testGoodUri("aaa%2Fbbb")); + + // ports + ASSERT_TRUE(testGoodUri("http://example.org:80/aaa/bbb#ccc")); + ASSERT_TRUE(testGoodUri("http://example.org:/aaa/bbb#ccc")); + ASSERT_TRUE(testGoodUri("http://example.org./aaa/bbb#ccc")); + ASSERT_TRUE(testGoodUri("http://example.123./aaa/bbb#ccc")); + + // bare authority + ASSERT_TRUE(testGoodUri("http://example.org")); + + // IPv6 literals (from RFC2732): + ASSERT_TRUE(testGoodUri("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html")); + ASSERT_TRUE(testGoodUri("http://[1080:0:0:0:8:800:200C:417A]/index.html")); + ASSERT_TRUE(testGoodUri("http://[3ffe:2a00:100:7031::1]")); + ASSERT_TRUE(testGoodUri("http://[1080::8:800:200C:417A]/foo")); + ASSERT_TRUE(testGoodUri("http://[::192.9.5.5]/ipng")); + ASSERT_TRUE(testGoodUri("http://[::FFFF:129.144.52.38]:80/index.html")); + ASSERT_TRUE(testGoodUri("http://[2010:836B:4179::836B:4179]")); + ASSERT_TRUE(testGoodUri("//[2010:836B:4179::836B:4179]")); + + // Random other things that crop up + ASSERT_TRUE(testGoodUri("http://example/Andrȷ")); + ASSERT_TRUE(testGoodUri("file:///C:/DEV/Haskell/lib/HXmlToolbox-3.01/examples/")); +} + + + +TEST(FourSuite, BadUriReferences) { + ASSERT_TRUE(testBadUri("beepbeep\x07\x07", 8)); + ASSERT_TRUE(testBadUri("\n", 0)); + ASSERT_TRUE(testBadUri("::", 0)); // not OK, per Roy Fielding on the W3C uri list on 2004-04-01 + + // the following test cases are from a Perl script by David A. Wheeler + // at http://www.dwheeler.com/secure-programs/url.pl + ASSERT_TRUE(testBadUri("http://www yahoo.com", 10)); + ASSERT_TRUE(testBadUri("http://www.yahoo.com/hello world/", 26)); + ASSERT_TRUE(testBadUri("http://www.yahoo.com/yelp.html#\"", 31)); + + // the following test cases are from a Haskell program by Graham Klyne + // at http://www.ninebynine.org/Software/HaskellUtils/Network/URITest.hs + ASSERT_TRUE(testBadUri("[2010:836B:4179::836B:4179]", 0)); + ASSERT_TRUE(testBadUri(" ", 0)); + ASSERT_TRUE(testBadUri("%", 1)); + ASSERT_TRUE(testBadUri("A%Z", 2)); + ASSERT_TRUE(testBadUri("%ZZ", 1)); + ASSERT_TRUE(testBadUri("%AZ", 2)); + ASSERT_TRUE(testBadUri("A C", 1)); + ASSERT_TRUE(testBadUri("A\\'C", 1)); // r"A\'C" + ASSERT_TRUE(testBadUri("A`C", 1)); + ASSERT_TRUE(testBadUri("A<C", 1)); + ASSERT_TRUE(testBadUri("A>C", 1)); + ASSERT_TRUE(testBadUri("A^C", 1)); + ASSERT_TRUE(testBadUri("A\\\\C", 1)); // r'A\\C' + ASSERT_TRUE(testBadUri("A{C", 1)); + ASSERT_TRUE(testBadUri("A|C", 1)); + ASSERT_TRUE(testBadUri("A}C", 1)); + ASSERT_TRUE(testBadUri("A[C", 1)); + ASSERT_TRUE(testBadUri("A]C", 1)); + ASSERT_TRUE(testBadUri("A[**]C", 1)); + ASSERT_TRUE(testBadUri("http://[xyz]/", 8)); + ASSERT_TRUE(testBadUri("http://]/", 7)); + ASSERT_TRUE(testBadUri("http://example.org/[2010:836B:4179::836B:4179]", 19)); + ASSERT_TRUE(testBadUri("http://example.org/abc#[2010:836B:4179::836B:4179]", 23)); + ASSERT_TRUE(testBadUri("http://example.org/xxx/[qwerty]#a[b]", 23)); + + // from a post to the W3C uri list on 2004-02-17 + // breaks at 22 instead of 17 because everything up to that point is a valid userinfo + ASSERT_TRUE(testBadUri("http://w3c.org:80path1/path2", 22)); +} + + + +namespace { + +bool normalizeAndCompare(const char * uriText, + const char * expectedNormalized) { + UriParserStateA stateA; + int res; + + UriUriA testUri; + stateA.uri = &testUri; + res = uriParseUriA(&stateA, uriText); + if (res != 0) { + uriFreeUriMembersA(&testUri); + return false; + } + + // Expected result + UriUriA expectedUri; + stateA.uri = &expectedUri; + res = uriParseUriA(&stateA, expectedNormalized); + if (res != 0) { + uriFreeUriMembersA(&testUri); + uriFreeUriMembersA(&expectedUri); + return false; + } + + res = uriNormalizeSyntaxA(&testUri); + if (res != 0) { + uriFreeUriMembersA(&testUri); + uriFreeUriMembersA(&expectedUri); + return false; + } + + const bool equalAfter = (URI_TRUE == uriEqualsUriA(&testUri, &expectedUri)); + uriFreeUriMembersA(&testUri); + uriFreeUriMembersA(&expectedUri); + return equalAfter; +} + +} // namespace + + + +TEST(FourSuite, CaseNormalizationTests) { + ASSERT_TRUE(normalizeAndCompare("HTTP://www.EXAMPLE.com/", "http://www.example.com/")); + ASSERT_TRUE(normalizeAndCompare("example://A/b/c/%7bfoo%7d", "example://a/b/c/%7Bfoo%7D")); +} + + + +TEST(FourSuite, PctEncNormalizationTests) { + ASSERT_TRUE(normalizeAndCompare("http://host/%7Euser/x/y/z", "http://host/~user/x/y/z")); + ASSERT_TRUE(normalizeAndCompare("http://host/%7euser/x/y/z", "http://host/~user/x/y/z")); +} + + + +TEST(FourSuite, PathSegmentNormalizationTests) { + ASSERT_TRUE(normalizeAndCompare("/a/b/../../c", "/c")); + // ASSERT_TRUE(normalizeAndCompare("a/b/../../c", "a/b/../../c")); + // Fixed: + ASSERT_TRUE(normalizeAndCompare("a/b/../../c", "c")); + ASSERT_TRUE(normalizeAndCompare("/a/b/././c", "/a/b/c")); + // ASSERT_TRUE(normalizeAndCompare("a/b/././c", "a/b/././c")); + // Fixed: + ASSERT_TRUE(normalizeAndCompare("a/b/././c", "a/b/c")); + ASSERT_TRUE(normalizeAndCompare("/a/b/../c/././d", "/a/c/d")); + // ASSERT_TRUE(normalizeAndCompare("a/b/../c/././d", "a/b/../c/././d")); + // Fixed: + ASSERT_TRUE(normalizeAndCompare("a/b/../c/././d", "a/c/d")); +} diff --git a/contrib/restricted/uriparser/test/MemoryManagerSuite.cpp b/contrib/restricted/uriparser/test/MemoryManagerSuite.cpp index 0abc263bca..6b684167b7 100644 --- a/contrib/restricted/uriparser/test/MemoryManagerSuite.cpp +++ b/contrib/restricted/uriparser/test/MemoryManagerSuite.cpp @@ -1,41 +1,41 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> - * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#undef NDEBUG // because we rely on assert(3) further down - -#include <cassert> -#include <cerrno> -#include <cstring> // memcpy -#include <gtest/gtest.h> - -#include <uriparser/Uri.h> +/* + * uriparser - RFC 3986 URI parsing library + * + * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> + * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#undef NDEBUG // because we rely on assert(3) further down + +#include <cassert> +#include <cerrno> +#include <cstring> // memcpy +#include <gtest/gtest.h> + +#include <uriparser/Uri.h> // For defaultMemoryManager extern "C" { -#include "../src/UriMemory.h" +#include "../src/UriMemory.h" } - - -namespace { - + + +namespace { + static void * failingMalloc(UriMemoryManager * memory, size_t size); @@ -50,9 +50,9 @@ class FailingMemoryManager { private: UriMemoryManager memoryManager; unsigned int callCountAlloc; - unsigned int callCountFree; + unsigned int callCountFree; unsigned int failAllocAfterTimes; - + friend void * failingMalloc(UriMemoryManager * memory, size_t size); friend void * failingCalloc(UriMemoryManager * memory, size_t nmemb, size_t size); friend void * failingRealloc(UriMemoryManager * memory, void * ptr, size_t size); @@ -69,7 +69,7 @@ public: this->memoryManager.reallocarray = failingReallocarray; this->memoryManager.free = countingFree; this->memoryManager.userData = this; - } + } UriMemoryManager * operator&() { return &(this->memoryManager); @@ -78,10 +78,10 @@ public: unsigned int getCallCountFree() const { return this->callCountFree; } -}; - - - +}; + + + static void * failingMalloc(UriMemoryManager * memory, size_t size) { FailingMemoryManager * const fmm = static_cast<FailingMemoryManager *>(memory->userData); fmm->callCountAlloc++; @@ -90,10 +90,10 @@ static void * failingMalloc(UriMemoryManager * memory, size_t size) { return NULL; } return malloc(size); -} - - - +} + + + static void * failingCalloc(UriMemoryManager * memory, size_t nmemb, size_t size) { FailingMemoryManager * const fmm = static_cast<FailingMemoryManager *>(memory->userData); fmm->callCountAlloc++; @@ -102,10 +102,10 @@ static void * failingCalloc(UriMemoryManager * memory, size_t nmemb, size_t size return NULL; } return calloc(nmemb, size); -} - - - +} + + + static void * failingRealloc(UriMemoryManager * memory, void * ptr, size_t size) { FailingMemoryManager * const fmm = static_cast<FailingMemoryManager *>(memory->userData); fmm->callCountAlloc++; @@ -114,253 +114,253 @@ static void * failingRealloc(UriMemoryManager * memory, void * ptr, size_t size) return NULL; } return realloc(ptr, size); -} - - - +} + + + static void * failingReallocarray(UriMemoryManager * memory, void * ptr, size_t nmemb, size_t size) { return uriEmulateReallocarray(memory, ptr, nmemb, size); -} - - - -static void countingFree(UriMemoryManager * memory, void * ptr) { +} + + + +static void countingFree(UriMemoryManager * memory, void * ptr) { FailingMemoryManager * const fmm = static_cast<FailingMemoryManager *>(memory->userData); fmm->callCountFree++; return free(ptr); -} - - - -static UriUriA parse(const char * sourceUriString) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - assert(uriParseUriA(&state, sourceUriString) == URI_SUCCESS); - return uri; -} - - - -static UriQueryListA * parseQueryList(const char * queryString) { - UriQueryListA * queryList; - const char * const first = queryString; - const char * const afterLast = first + strlen(first); - assert(uriDissectQueryMallocA(&queryList, NULL, first, afterLast) - == URI_SUCCESS); - return queryList; -} - -} // namespace - - - -TEST(MemoryManagerCompletenessSuite, AllFunctionMembersRequired) { - UriUriA uri = parse("whatever"); - UriMemoryManager memory; - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.malloc = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.calloc = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.realloc = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.reallocarray = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - memory.free = NULL; - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); - ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), URI_SUCCESS); -} - - - -TEST(MemoryManagerCompletenessSuite, MallocAndFreeRequiredOnly) { - UriMemoryManager memory; - UriMemoryManager backend; - - memcpy(&backend, &defaultMemoryManager, sizeof(UriMemoryManager)); - backend.malloc = NULL; - ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); - - memcpy(&backend, &defaultMemoryManager, sizeof(UriMemoryManager)); - backend.free = NULL; - ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), - URI_ERROR_MEMORY_MANAGER_INCOMPLETE); -} - - - +} + + + +static UriUriA parse(const char * sourceUriString) { + UriParserStateA state; + UriUriA uri; + state.uri = &uri; + assert(uriParseUriA(&state, sourceUriString) == URI_SUCCESS); + return uri; +} + + + +static UriQueryListA * parseQueryList(const char * queryString) { + UriQueryListA * queryList; + const char * const first = queryString; + const char * const afterLast = first + strlen(first); + assert(uriDissectQueryMallocA(&queryList, NULL, first, afterLast) + == URI_SUCCESS); + return queryList; +} + +} // namespace + + + +TEST(MemoryManagerCompletenessSuite, AllFunctionMembersRequired) { + UriUriA uri = parse("whatever"); + UriMemoryManager memory; + + memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); + memory.malloc = NULL; + ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), + URI_ERROR_MEMORY_MANAGER_INCOMPLETE); + + memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); + memory.calloc = NULL; + ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), + URI_ERROR_MEMORY_MANAGER_INCOMPLETE); + + memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); + memory.realloc = NULL; + ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), + URI_ERROR_MEMORY_MANAGER_INCOMPLETE); + + memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); + memory.reallocarray = NULL; + ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), + URI_ERROR_MEMORY_MANAGER_INCOMPLETE); + + memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); + memory.free = NULL; + ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), + URI_ERROR_MEMORY_MANAGER_INCOMPLETE); + + memcpy(&memory, &defaultMemoryManager, sizeof(UriMemoryManager)); + ASSERT_EQ(uriFreeUriMembersMmA(&uri, &memory), URI_SUCCESS); +} + + + +TEST(MemoryManagerCompletenessSuite, MallocAndFreeRequiredOnly) { + UriMemoryManager memory; + UriMemoryManager backend; + + memcpy(&backend, &defaultMemoryManager, sizeof(UriMemoryManager)); + backend.malloc = NULL; + ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), + URI_ERROR_MEMORY_MANAGER_INCOMPLETE); + + memcpy(&backend, &defaultMemoryManager, sizeof(UriMemoryManager)); + backend.free = NULL; + ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), + URI_ERROR_MEMORY_MANAGER_INCOMPLETE); +} + + + TEST(MemoryManagerTestingSuite, DISABLED_DefaultMemoryManager) { - ASSERT_EQ(uriTestMemoryManager(&defaultMemoryManager), URI_SUCCESS); -} - - - -TEST(MemoryManagerTestingSuite, CompleteMemoryManager) { - UriMemoryManager memory; - UriMemoryManager backend; - - memset(&backend, 0, sizeof(UriMemoryManager)); - backend.malloc = defaultMemoryManager.malloc; - backend.free = defaultMemoryManager.free; - - ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), - URI_SUCCESS); - - ASSERT_EQ(uriTestMemoryManager(&memory), URI_SUCCESS); -} - - - + ASSERT_EQ(uriTestMemoryManager(&defaultMemoryManager), URI_SUCCESS); +} + + + +TEST(MemoryManagerTestingSuite, CompleteMemoryManager) { + UriMemoryManager memory; + UriMemoryManager backend; + + memset(&backend, 0, sizeof(UriMemoryManager)); + backend.malloc = defaultMemoryManager.malloc; + backend.free = defaultMemoryManager.free; + + ASSERT_EQ(uriCompleteMemoryManager(&memory, &backend), + URI_SUCCESS); + + ASSERT_EQ(uriTestMemoryManager(&memory), URI_SUCCESS); +} + + + TEST(MemoryManagerTestingSuite, DISABLED_EmulateCalloc) { - UriMemoryManager partialEmulationMemoryManager; - memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, - sizeof(UriMemoryManager)); - partialEmulationMemoryManager.calloc = uriEmulateCalloc; - - ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), - URI_SUCCESS); -} - - - -TEST(MemoryManagerTestingSuite, EmulateReallocarray) { - UriMemoryManager partialEmulationMemoryManager; - memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, - sizeof(UriMemoryManager)); - partialEmulationMemoryManager.reallocarray = uriEmulateReallocarray; - - ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), - URI_SUCCESS); -} - - - -TEST(MemoryManagerTestingOverflowDetectionSuite, EmulateCalloc) { - EXPECT_GT(2 * sizeof(size_t), sizeof(void *)); - - errno = 0; - ASSERT_EQ(NULL, uriEmulateCalloc( - &defaultMemoryManager, (size_t)-1, (size_t)-1)); - ASSERT_EQ(errno, ENOMEM); -} - - - -TEST(MemoryManagerTestingOverflowDetectionSuite, EmulateReallocarray) { - EXPECT_GT(2 * sizeof(size_t), sizeof(void *)); - - errno = 0; - ASSERT_EQ(NULL, uriEmulateReallocarray( - &defaultMemoryManager, NULL, (size_t)-1, (size_t)-1)); - ASSERT_EQ(errno, ENOMEM); -} - - - -TEST(MemoryManagerTestingSuite, EmulateCallocAndReallocarray) { - UriMemoryManager partialEmulationMemoryManager; - memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, - sizeof(UriMemoryManager)); - partialEmulationMemoryManager.calloc = uriEmulateCalloc; - partialEmulationMemoryManager.reallocarray = uriEmulateReallocarray; - - ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), - URI_SUCCESS); -} - - - -TEST(FailingMemoryManagerSuite, AddBaseUriExMm) { - UriUriA absoluteDest; - UriUriA relativeSource = parse("foo"); - UriUriA absoluteBase = parse("http://example.org/bar"); - const UriResolutionOptions options = URI_RESOLVE_STRICTLY; - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriAddBaseUriExMmA(&absoluteDest, &relativeSource, - &absoluteBase, options, &failingMemoryManager), - URI_ERROR_MALLOC); - - uriFreeUriMembersA(&relativeSource); - uriFreeUriMembersA(&absoluteBase); -} - - - -TEST(FailingMemoryManagerSuite, ComposeQueryMallocExMm) { - char * dest = NULL; - UriQueryListA * const queryList = parseQueryList("k1=v1"); - UriBool spaceToPlus = URI_TRUE; // not of interest - UriBool normalizeBreaks = URI_TRUE; // not of interest - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriComposeQueryMallocExMmA(&dest, queryList, - spaceToPlus, normalizeBreaks, &failingMemoryManager), - URI_ERROR_MALLOC); - - uriFreeQueryListA(queryList); -} - - - -TEST(FailingMemoryManagerSuite, DissectQueryMallocExMm) { - UriQueryListA * queryList; - int itemCount; - const char * const first = "k1=v1&k2=v2"; - const char * const afterLast = first + strlen(first); - const UriBool plusToSpace = URI_TRUE; // not of interest - const UriBreakConversion breakConversion = URI_BR_DONT_TOUCH; // not o. i. - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriDissectQueryMallocExMmA(&queryList, &itemCount, - first, afterLast, plusToSpace, breakConversion, - &failingMemoryManager), - URI_ERROR_MALLOC); -} - - - -TEST(FailingMemoryManagerSuite, FreeQueryListMm) { - UriQueryListA * const queryList = parseQueryList("k1=v1"); - FailingMemoryManager failingMemoryManager; + UriMemoryManager partialEmulationMemoryManager; + memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, + sizeof(UriMemoryManager)); + partialEmulationMemoryManager.calloc = uriEmulateCalloc; + + ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), + URI_SUCCESS); +} + + + +TEST(MemoryManagerTestingSuite, EmulateReallocarray) { + UriMemoryManager partialEmulationMemoryManager; + memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, + sizeof(UriMemoryManager)); + partialEmulationMemoryManager.reallocarray = uriEmulateReallocarray; + + ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), + URI_SUCCESS); +} + + + +TEST(MemoryManagerTestingOverflowDetectionSuite, EmulateCalloc) { + EXPECT_GT(2 * sizeof(size_t), sizeof(void *)); + + errno = 0; + ASSERT_EQ(NULL, uriEmulateCalloc( + &defaultMemoryManager, (size_t)-1, (size_t)-1)); + ASSERT_EQ(errno, ENOMEM); +} + + + +TEST(MemoryManagerTestingOverflowDetectionSuite, EmulateReallocarray) { + EXPECT_GT(2 * sizeof(size_t), sizeof(void *)); + + errno = 0; + ASSERT_EQ(NULL, uriEmulateReallocarray( + &defaultMemoryManager, NULL, (size_t)-1, (size_t)-1)); + ASSERT_EQ(errno, ENOMEM); +} + + + +TEST(MemoryManagerTestingSuite, EmulateCallocAndReallocarray) { + UriMemoryManager partialEmulationMemoryManager; + memcpy(&partialEmulationMemoryManager, &defaultMemoryManager, + sizeof(UriMemoryManager)); + partialEmulationMemoryManager.calloc = uriEmulateCalloc; + partialEmulationMemoryManager.reallocarray = uriEmulateReallocarray; + + ASSERT_EQ(uriTestMemoryManager(&partialEmulationMemoryManager), + URI_SUCCESS); +} + + + +TEST(FailingMemoryManagerSuite, AddBaseUriExMm) { + UriUriA absoluteDest; + UriUriA relativeSource = parse("foo"); + UriUriA absoluteBase = parse("http://example.org/bar"); + const UriResolutionOptions options = URI_RESOLVE_STRICTLY; + FailingMemoryManager failingMemoryManager; + + ASSERT_EQ(uriAddBaseUriExMmA(&absoluteDest, &relativeSource, + &absoluteBase, options, &failingMemoryManager), + URI_ERROR_MALLOC); + + uriFreeUriMembersA(&relativeSource); + uriFreeUriMembersA(&absoluteBase); +} + + + +TEST(FailingMemoryManagerSuite, ComposeQueryMallocExMm) { + char * dest = NULL; + UriQueryListA * const queryList = parseQueryList("k1=v1"); + UriBool spaceToPlus = URI_TRUE; // not of interest + UriBool normalizeBreaks = URI_TRUE; // not of interest + FailingMemoryManager failingMemoryManager; + + ASSERT_EQ(uriComposeQueryMallocExMmA(&dest, queryList, + spaceToPlus, normalizeBreaks, &failingMemoryManager), + URI_ERROR_MALLOC); + + uriFreeQueryListA(queryList); +} + + + +TEST(FailingMemoryManagerSuite, DissectQueryMallocExMm) { + UriQueryListA * queryList; + int itemCount; + const char * const first = "k1=v1&k2=v2"; + const char * const afterLast = first + strlen(first); + const UriBool plusToSpace = URI_TRUE; // not of interest + const UriBreakConversion breakConversion = URI_BR_DONT_TOUCH; // not o. i. + FailingMemoryManager failingMemoryManager; + + ASSERT_EQ(uriDissectQueryMallocExMmA(&queryList, &itemCount, + first, afterLast, plusToSpace, breakConversion, + &failingMemoryManager), + URI_ERROR_MALLOC); +} + + + +TEST(FailingMemoryManagerSuite, FreeQueryListMm) { + UriQueryListA * const queryList = parseQueryList("k1=v1"); + FailingMemoryManager failingMemoryManager; ASSERT_EQ(failingMemoryManager.getCallCountFree(), 0U); - - uriFreeQueryListMmA(queryList, &failingMemoryManager); - + + uriFreeQueryListMmA(queryList, &failingMemoryManager); + ASSERT_GE(failingMemoryManager.getCallCountFree(), 1U); -} - - - -TEST(FailingMemoryManagerSuite, FreeUriMembersMm) { - UriUriA uri = parse("http://example.org/"); - FailingMemoryManager failingMemoryManager; +} + + + +TEST(FailingMemoryManagerSuite, FreeUriMembersMm) { + UriUriA uri = parse("http://example.org/"); + FailingMemoryManager failingMemoryManager; ASSERT_EQ(failingMemoryManager.getCallCountFree(), 0U); - - uriFreeUriMembersMmA(&uri, &failingMemoryManager); - + + uriFreeUriMembersMmA(&uri, &failingMemoryManager); + ASSERT_GE(failingMemoryManager.getCallCountFree(), 1U); - uriFreeUriMembersA(&uri); -} - + uriFreeUriMembersA(&uri); +} + namespace { void testNormalizeSyntaxWithFailingMallocCallsFreeTimes(const char * uriString, unsigned int mask, @@ -368,28 +368,28 @@ namespace { unsigned int expectedCallCountFree = 0) { UriUriA uri = parse(uriString); FailingMemoryManager failingMemoryManager(failAllocAfterTimes); - + ASSERT_EQ(uriNormalizeSyntaxExMmA(&uri, mask, &failingMemoryManager), URI_ERROR_MALLOC); - + EXPECT_EQ(failingMemoryManager.getCallCountFree(), expectedCallCountFree); - + uriFreeUriMembersA(&uri); } } // namespace - + TEST(FailingMemoryManagerSuite, NormalizeSyntaxExMmScheme) { testNormalizeSyntaxWithFailingMallocCallsFreeTimes("hTTp://example.org/path", URI_NORMALIZE_SCHEME); -} - +} + TEST(FailingMemoryManagerSuite, NormalizeSyntaxExMmEmptyUserInfo) { testNormalizeSyntaxWithFailingMallocCallsFreeTimes("//@:123", URI_NORMALIZE_USER_INFO); } - + TEST(FailingMemoryManagerSuite, NormalizeSyntaxExMmEmptyHostRegname) { testNormalizeSyntaxWithFailingMallocCallsFreeTimes("//:123", URI_NORMALIZE_HOST); } - + TEST(FailingMemoryManagerSuite, NormalizeSyntaxExMmEmptyQuery) { testNormalizeSyntaxWithFailingMallocCallsFreeTimes("//:123?", URI_NORMALIZE_QUERY); } @@ -416,30 +416,30 @@ TEST(FailingMemoryManagerSuite, NormalizeSyntaxExMmHostTextFuture) { // issue # -TEST(FailingMemoryManagerSuite, ParseSingleUriExMm) { - UriUriA uri; - const char * const first = "k1=v1&k2=v2"; - const char * const afterLast = first + strlen(first); - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriParseSingleUriExMmA(&uri, first, afterLast, NULL, - &failingMemoryManager), - URI_ERROR_MALLOC); -} - - - -TEST(FailingMemoryManagerSuite, RemoveBaseUriMm) { - UriUriA dest; - UriUriA absoluteSource = parse("http://example.org/a/b/c/"); - UriUriA absoluteBase = parse("http://example.org/a/"); - const UriBool domainRootMode = URI_TRUE; // not of interest - FailingMemoryManager failingMemoryManager; - - ASSERT_EQ(uriRemoveBaseUriMmA(&dest, &absoluteSource, &absoluteBase, - domainRootMode, &failingMemoryManager), - URI_ERROR_MALLOC); - - uriFreeUriMembersA(&absoluteSource); - uriFreeUriMembersA(&absoluteBase); -} +TEST(FailingMemoryManagerSuite, ParseSingleUriExMm) { + UriUriA uri; + const char * const first = "k1=v1&k2=v2"; + const char * const afterLast = first + strlen(first); + FailingMemoryManager failingMemoryManager; + + ASSERT_EQ(uriParseSingleUriExMmA(&uri, first, afterLast, NULL, + &failingMemoryManager), + URI_ERROR_MALLOC); +} + + + +TEST(FailingMemoryManagerSuite, RemoveBaseUriMm) { + UriUriA dest; + UriUriA absoluteSource = parse("http://example.org/a/b/c/"); + UriUriA absoluteBase = parse("http://example.org/a/"); + const UriBool domainRootMode = URI_TRUE; // not of interest + FailingMemoryManager failingMemoryManager; + + ASSERT_EQ(uriRemoveBaseUriMmA(&dest, &absoluteSource, &absoluteBase, + domainRootMode, &failingMemoryManager), + URI_ERROR_MALLOC); + + uriFreeUriMembersA(&absoluteSource); + uriFreeUriMembersA(&absoluteBase); +} diff --git a/contrib/restricted/uriparser/test/VersionSuite.cpp b/contrib/restricted/uriparser/test/VersionSuite.cpp index a46f0d59b3..014ecce385 100644 --- a/contrib/restricted/uriparser/test/VersionSuite.cpp +++ b/contrib/restricted/uriparser/test/VersionSuite.cpp @@ -1,43 +1,43 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2014, Sebastian Pipping <sebastian@pipping.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <gtest/gtest.h> - -#include <cstdio> - - -#include <config.h> // for PACKAGE_VERSION -#include <uriparser/UriBase.h> - - -TEST(VersionSuite, EnsureVersionDefinesInSync) { - char INSIDE_VERSION[256]; - const int bytes_printed = sprintf(INSIDE_VERSION, "%d.%d.%d%s", - URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, URI_VER_SUFFIX_ANSI); - ASSERT_TRUE(bytes_printed != -1); - - const bool equal = !strcmp(INSIDE_VERSION, PACKAGE_VERSION); - if (! equal) { - printf("Inside/outside version mismatch detected:\n"); - printf(" Tarball version: <%s>\n", PACKAGE_VERSION); - printf(" Header defines version: <%s>\n", INSIDE_VERSION); - } - ASSERT_TRUE(equal); -} +/* + * uriparser - RFC 3986 URI parsing library + * + * Copyright (C) 2014, Sebastian Pipping <sebastian@pipping.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <gtest/gtest.h> + +#include <cstdio> + + +#include <config.h> // for PACKAGE_VERSION +#include <uriparser/UriBase.h> + + +TEST(VersionSuite, EnsureVersionDefinesInSync) { + char INSIDE_VERSION[256]; + const int bytes_printed = sprintf(INSIDE_VERSION, "%d.%d.%d%s", + URI_VER_MAJOR, URI_VER_MINOR, URI_VER_RELEASE, URI_VER_SUFFIX_ANSI); + ASSERT_TRUE(bytes_printed != -1); + + const bool equal = !strcmp(INSIDE_VERSION, PACKAGE_VERSION); + if (! equal) { + printf("Inside/outside version mismatch detected:\n"); + printf(" Tarball version: <%s>\n", PACKAGE_VERSION); + printf(" Header defines version: <%s>\n", INSIDE_VERSION); + } + ASSERT_TRUE(equal); +} diff --git a/contrib/restricted/uriparser/test/test.cpp b/contrib/restricted/uriparser/test/test.cpp index 8580399733..12166e0c1c 100644 --- a/contrib/restricted/uriparser/test/test.cpp +++ b/contrib/restricted/uriparser/test/test.cpp @@ -1,1103 +1,1103 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> - * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <uriparser/Uri.h> -#include <uriparser/UriIp4.h> -#include <gtest/gtest.h> -#include <memory> -#include <cstdio> -#include <cstdlib> -#include <cwchar> - -using namespace std; - - - -extern "C" { -UriBool uri_TESTING_ONLY_ParseIpSixA(const char * text); -UriBool uri_TESTING_ONLY_ParseIpFourA(const char * text); -int uriCompareRangeA(const UriTextRangeA * a, const UriTextRangeA * b); -} - - - -#define URI_TEST_IP_FOUR_FAIL(x) ASSERT_TRUE(URI_FALSE == uri_TESTING_ONLY_ParseIpFourA(x)) -#define URI_TEST_IP_FOUR_PASS(x) ASSERT_TRUE(URI_TRUE == uri_TESTING_ONLY_ParseIpFourA(x)) - -// Note the closing brackets! TODO -#define URI_TEST_IP_SIX_FAIL(x) ASSERT_TRUE(URI_FALSE == uri_TESTING_ONLY_ParseIpSixA(x "]")) -#define URI_TEST_IP_SIX_PASS(x) ASSERT_TRUE(URI_TRUE == uri_TESTING_ONLY_ParseIpSixA(x "]")) - -#define URI_EXPECT_BETWEEN(candidate, first, afterLast) \ - EXPECT_TRUE((candidate >= first) && (candidate <= afterLast)) - -#define URI_EXPECT_OUTSIDE(candidate, first, afterLast) \ - EXPECT_TRUE((candidate < first) || (candidate > afterLast)) - -#define URI_EXPECT_RANGE_BETWEEN(range, uriFirst, uriAfterLast) \ - URI_EXPECT_BETWEEN(range.first, uriFirst, uriAfterLast); \ - URI_EXPECT_BETWEEN(range.afterLast, uriFirst, uriAfterLast) - -#define URI_EXPECT_RANGE_OUTSIDE(range, uriFirst, uriAfterLast) \ - URI_EXPECT_OUTSIDE(range.first, uriFirst, uriAfterLast); \ - URI_EXPECT_OUTSIDE(range.afterLast, uriFirst, uriAfterLast) - -#define URI_EXPECT_RANGE_EMPTY(range) \ - EXPECT_TRUE((range.first != NULL) \ - && (range.afterLast != NULL) \ - && (range.first == range.afterLast)) - -namespace { - bool testDistinctionHelper(const char * uriText, bool expectedHostSet, - bool expectedAbsPath, bool expectedEmptyTailSegment) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - - int res = uriParseUriA(&state, uriText); - if (res != URI_SUCCESS) { - uriFreeUriMembersA(&uri); - return false; - } - - if (expectedHostSet != (uri.hostText.first != NULL)) { - uriFreeUriMembersA(&uri); - return false; - } - - if (expectedAbsPath != (uri.absolutePath == URI_TRUE)) { - uriFreeUriMembersA(&uri); - return false; - } - - if (expectedEmptyTailSegment != ((uri.pathTail != NULL) - && (uri.pathTail->text.first == uri.pathTail->text.afterLast))) { - uriFreeUriMembersA(&uri); - return false; - } - - uriFreeUriMembersA(&uri); - return true; - } -} // namespace - - -TEST(UriSuite, TestDistinction) { - /* -============================================================================ -Rule | Example | hostSet | absPath | emptySeg -------------------------------------|---------|---------|---------|--------- -1) URI = scheme ":" hier-part ... | | | | - 1) "//" authority path-abempty | "s://" | true | false | false - | "s:///" | true | false | true - | "s://a" | true | false | false - | "s://a/"| true | false | true - 2) path-absolute | "s:/" | false | true | false - 3) path-rootless | "s:a" | false | false | false - | "s:a/" | false | false | true - 4) path-empty | "s:" | false | false | false -------------------------------------|---------|---------|---------|--------- -2) relative-ref = relative-part ... | | | | - 1) "//" authority path-abempty | "//" | true | false | false - | "///" | true | false | true - 2) path-absolute | "/" | false | true | false - 3) path-noscheme | "a" | false | false | false - | "a/" | false | false | true - 4) path-empty | "" | false | false | false -============================================================================ - */ - ASSERT_TRUE(testDistinctionHelper("s://", true, false, false)); - ASSERT_TRUE(testDistinctionHelper("s:///", true, false, true)); - ASSERT_TRUE(testDistinctionHelper("s://a", true, false, false)); - ASSERT_TRUE(testDistinctionHelper("s://a/", true, false, true)); - ASSERT_TRUE(testDistinctionHelper("s:/", false, true, false)); - ASSERT_TRUE(testDistinctionHelper("s:a", false, false, false)); - ASSERT_TRUE(testDistinctionHelper("s:a/", false, false, true)); - ASSERT_TRUE(testDistinctionHelper("s:", false, false, false)); - - ASSERT_TRUE(testDistinctionHelper("//", true, false, false)); - ASSERT_TRUE(testDistinctionHelper("///", true, false, true)); - ASSERT_TRUE(testDistinctionHelper("/", false, true, false)); - ASSERT_TRUE(testDistinctionHelper("a", false, false, false)); - ASSERT_TRUE(testDistinctionHelper("a/", false, false, true)); - ASSERT_TRUE(testDistinctionHelper("", false, false, false)); -} - -TEST(UriSuite, TestIpFour) { - URI_TEST_IP_FOUR_FAIL("01.0.0.0"); - URI_TEST_IP_FOUR_FAIL("001.0.0.0"); - URI_TEST_IP_FOUR_FAIL("00.0.0.0"); - URI_TEST_IP_FOUR_FAIL("000.0.0.0"); - URI_TEST_IP_FOUR_FAIL("256.0.0.0"); - URI_TEST_IP_FOUR_FAIL("300.0.0.0"); - URI_TEST_IP_FOUR_FAIL("1111.0.0.0"); - URI_TEST_IP_FOUR_FAIL("-1.0.0.0"); - URI_TEST_IP_FOUR_FAIL("0.0.0"); - URI_TEST_IP_FOUR_FAIL("0.0.0."); - URI_TEST_IP_FOUR_FAIL("0.0.0.0."); - URI_TEST_IP_FOUR_FAIL("0.0.0.0.0"); - URI_TEST_IP_FOUR_FAIL("0.0..0"); - URI_TEST_IP_FOUR_FAIL(".0.0.0"); - - URI_TEST_IP_FOUR_PASS("255.0.0.0"); - URI_TEST_IP_FOUR_PASS("0.0.0.0"); - URI_TEST_IP_FOUR_PASS("1.0.0.0"); - URI_TEST_IP_FOUR_PASS("2.0.0.0"); - URI_TEST_IP_FOUR_PASS("3.0.0.0"); - URI_TEST_IP_FOUR_PASS("30.0.0.0"); -} - -TEST(UriSuite, TestIpSixPass) { - // Quad length - URI_TEST_IP_SIX_PASS("abcd::"); - - URI_TEST_IP_SIX_PASS("abcd::1"); - URI_TEST_IP_SIX_PASS("abcd::12"); - URI_TEST_IP_SIX_PASS("abcd::123"); - URI_TEST_IP_SIX_PASS("abcd::1234"); - - // Full length - URI_TEST_IP_SIX_PASS("2001:0db8:0100:f101:0210:a4ff:fee3:9566"); // lower hex - URI_TEST_IP_SIX_PASS("2001:0DB8:0100:F101:0210:A4FF:FEE3:9566"); // Upper hex - URI_TEST_IP_SIX_PASS("2001:db8:100:f101:210:a4ff:fee3:9566"); - URI_TEST_IP_SIX_PASS("2001:0db8:100:f101:0:0:0:1"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5:6:255.255.255.255"); - - // Legal IPv4 - URI_TEST_IP_SIX_PASS("::1.2.3.4"); - URI_TEST_IP_SIX_PASS("3:4::5:1.2.3.4"); - URI_TEST_IP_SIX_PASS("::ffff:1.2.3.4"); - URI_TEST_IP_SIX_PASS("::0.0.0.0"); // Min IPv4 - URI_TEST_IP_SIX_PASS("::255.255.255.255"); // Max IPv4 - - // Zipper position - URI_TEST_IP_SIX_PASS("::1:2:3:4:5:6:7"); - URI_TEST_IP_SIX_PASS("1::1:2:3:4:5:6"); - URI_TEST_IP_SIX_PASS("1:2::1:2:3:4:5"); - URI_TEST_IP_SIX_PASS("1:2:3::1:2:3:4"); - URI_TEST_IP_SIX_PASS("1:2:3:4::1:2:3"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5::1:2"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5:6::1"); - URI_TEST_IP_SIX_PASS("1:2:3:4:5:6:7::"); - - // Zipper length - URI_TEST_IP_SIX_PASS("1:1:1::1:1:1:1"); - URI_TEST_IP_SIX_PASS("1:1:1::1:1:1"); - URI_TEST_IP_SIX_PASS("1:1:1::1:1"); - URI_TEST_IP_SIX_PASS("1:1::1:1"); - URI_TEST_IP_SIX_PASS("1:1::1"); - URI_TEST_IP_SIX_PASS("1::1"); - URI_TEST_IP_SIX_PASS("::1"); // == localhost - URI_TEST_IP_SIX_PASS("::"); // == all addresses - - // A few more variations - URI_TEST_IP_SIX_PASS("21ff:abcd::1"); - URI_TEST_IP_SIX_PASS("2001:db8:100:f101::1"); - URI_TEST_IP_SIX_PASS("a:b:c::12:1"); - URI_TEST_IP_SIX_PASS("a:b::0:1:2:3"); -} - -TEST(UriSuite, TestIpSixFail) { - // 5 char quad - URI_TEST_IP_SIX_FAIL("::12345"); - - // Two zippers - URI_TEST_IP_SIX_FAIL("abcd::abcd::abcd"); - - // Triple-colon zipper - URI_TEST_IP_SIX_FAIL(":::1234"); - URI_TEST_IP_SIX_FAIL("1234:::1234:1234"); - URI_TEST_IP_SIX_FAIL("1234:1234:::1234"); - URI_TEST_IP_SIX_FAIL("1234:::"); - - // No quads, just IPv4 - URI_TEST_IP_SIX_FAIL("1.2.3.4"); - URI_TEST_IP_SIX_FAIL("0001.0002.0003.0004"); - - // Five quads - URI_TEST_IP_SIX_FAIL("0000:0000:0000:0000:0000:1.2.3.4"); - - // Seven quads - URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0"); - URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0:"); - URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0:1.2.3.4"); - - // Nine quads (or more) - URI_TEST_IP_SIX_FAIL("1:2:3:4:5:6:7:8:9"); - URI_TEST_IP_SIX_FAIL("::2:3:4:5:6:7:8:9"); - URI_TEST_IP_SIX_FAIL("1:2:3:4::6:7:8:9"); - URI_TEST_IP_SIX_FAIL("1:2:3:4:5:6:7:8::"); - - // Invalid IPv4 part - URI_TEST_IP_SIX_FAIL("::ffff:001.02.03.004"); // Leading zeros - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.1111"); // Four char octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.256"); // > 255 - URI_TEST_IP_SIX_FAIL("::ffff:311.2.3.4"); // > 155 - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3:4"); // Not a dot - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3"); // Missing octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3."); // Missing octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3a.4"); // Hex in octet - URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.4:123"); // Crap input - - // Nonhex - URI_TEST_IP_SIX_FAIL("g:0:0:0:0:0:0"); -} - -TEST(UriSuite, TestIpSixOverread) { - UriUriA uri; - const char * errorPos; - - // NOTE: This string is designed to not have a terminator - char uriText[2 + 3 + 2 + 1 + 1]; +/* + * uriparser - RFC 3986 URI parsing library + * + * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> + * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <uriparser/Uri.h> +#include <uriparser/UriIp4.h> +#include <gtest/gtest.h> +#include <memory> +#include <cstdio> +#include <cstdlib> +#include <cwchar> + +using namespace std; + + + +extern "C" { +UriBool uri_TESTING_ONLY_ParseIpSixA(const char * text); +UriBool uri_TESTING_ONLY_ParseIpFourA(const char * text); +int uriCompareRangeA(const UriTextRangeA * a, const UriTextRangeA * b); +} + + + +#define URI_TEST_IP_FOUR_FAIL(x) ASSERT_TRUE(URI_FALSE == uri_TESTING_ONLY_ParseIpFourA(x)) +#define URI_TEST_IP_FOUR_PASS(x) ASSERT_TRUE(URI_TRUE == uri_TESTING_ONLY_ParseIpFourA(x)) + +// Note the closing brackets! TODO +#define URI_TEST_IP_SIX_FAIL(x) ASSERT_TRUE(URI_FALSE == uri_TESTING_ONLY_ParseIpSixA(x "]")) +#define URI_TEST_IP_SIX_PASS(x) ASSERT_TRUE(URI_TRUE == uri_TESTING_ONLY_ParseIpSixA(x "]")) + +#define URI_EXPECT_BETWEEN(candidate, first, afterLast) \ + EXPECT_TRUE((candidate >= first) && (candidate <= afterLast)) + +#define URI_EXPECT_OUTSIDE(candidate, first, afterLast) \ + EXPECT_TRUE((candidate < first) || (candidate > afterLast)) + +#define URI_EXPECT_RANGE_BETWEEN(range, uriFirst, uriAfterLast) \ + URI_EXPECT_BETWEEN(range.first, uriFirst, uriAfterLast); \ + URI_EXPECT_BETWEEN(range.afterLast, uriFirst, uriAfterLast) + +#define URI_EXPECT_RANGE_OUTSIDE(range, uriFirst, uriAfterLast) \ + URI_EXPECT_OUTSIDE(range.first, uriFirst, uriAfterLast); \ + URI_EXPECT_OUTSIDE(range.afterLast, uriFirst, uriAfterLast) + +#define URI_EXPECT_RANGE_EMPTY(range) \ + EXPECT_TRUE((range.first != NULL) \ + && (range.afterLast != NULL) \ + && (range.first == range.afterLast)) + +namespace { + bool testDistinctionHelper(const char * uriText, bool expectedHostSet, + bool expectedAbsPath, bool expectedEmptyTailSegment) { + UriParserStateA state; + UriUriA uri; + state.uri = &uri; + + int res = uriParseUriA(&state, uriText); + if (res != URI_SUCCESS) { + uriFreeUriMembersA(&uri); + return false; + } + + if (expectedHostSet != (uri.hostText.first != NULL)) { + uriFreeUriMembersA(&uri); + return false; + } + + if (expectedAbsPath != (uri.absolutePath == URI_TRUE)) { + uriFreeUriMembersA(&uri); + return false; + } + + if (expectedEmptyTailSegment != ((uri.pathTail != NULL) + && (uri.pathTail->text.first == uri.pathTail->text.afterLast))) { + uriFreeUriMembersA(&uri); + return false; + } + + uriFreeUriMembersA(&uri); + return true; + } +} // namespace + + +TEST(UriSuite, TestDistinction) { + /* +============================================================================ +Rule | Example | hostSet | absPath | emptySeg +------------------------------------|---------|---------|---------|--------- +1) URI = scheme ":" hier-part ... | | | | + 1) "//" authority path-abempty | "s://" | true | false | false + | "s:///" | true | false | true + | "s://a" | true | false | false + | "s://a/"| true | false | true + 2) path-absolute | "s:/" | false | true | false + 3) path-rootless | "s:a" | false | false | false + | "s:a/" | false | false | true + 4) path-empty | "s:" | false | false | false +------------------------------------|---------|---------|---------|--------- +2) relative-ref = relative-part ... | | | | + 1) "//" authority path-abempty | "//" | true | false | false + | "///" | true | false | true + 2) path-absolute | "/" | false | true | false + 3) path-noscheme | "a" | false | false | false + | "a/" | false | false | true + 4) path-empty | "" | false | false | false +============================================================================ + */ + ASSERT_TRUE(testDistinctionHelper("s://", true, false, false)); + ASSERT_TRUE(testDistinctionHelper("s:///", true, false, true)); + ASSERT_TRUE(testDistinctionHelper("s://a", true, false, false)); + ASSERT_TRUE(testDistinctionHelper("s://a/", true, false, true)); + ASSERT_TRUE(testDistinctionHelper("s:/", false, true, false)); + ASSERT_TRUE(testDistinctionHelper("s:a", false, false, false)); + ASSERT_TRUE(testDistinctionHelper("s:a/", false, false, true)); + ASSERT_TRUE(testDistinctionHelper("s:", false, false, false)); + + ASSERT_TRUE(testDistinctionHelper("//", true, false, false)); + ASSERT_TRUE(testDistinctionHelper("///", true, false, true)); + ASSERT_TRUE(testDistinctionHelper("/", false, true, false)); + ASSERT_TRUE(testDistinctionHelper("a", false, false, false)); + ASSERT_TRUE(testDistinctionHelper("a/", false, false, true)); + ASSERT_TRUE(testDistinctionHelper("", false, false, false)); +} + +TEST(UriSuite, TestIpFour) { + URI_TEST_IP_FOUR_FAIL("01.0.0.0"); + URI_TEST_IP_FOUR_FAIL("001.0.0.0"); + URI_TEST_IP_FOUR_FAIL("00.0.0.0"); + URI_TEST_IP_FOUR_FAIL("000.0.0.0"); + URI_TEST_IP_FOUR_FAIL("256.0.0.0"); + URI_TEST_IP_FOUR_FAIL("300.0.0.0"); + URI_TEST_IP_FOUR_FAIL("1111.0.0.0"); + URI_TEST_IP_FOUR_FAIL("-1.0.0.0"); + URI_TEST_IP_FOUR_FAIL("0.0.0"); + URI_TEST_IP_FOUR_FAIL("0.0.0."); + URI_TEST_IP_FOUR_FAIL("0.0.0.0."); + URI_TEST_IP_FOUR_FAIL("0.0.0.0.0"); + URI_TEST_IP_FOUR_FAIL("0.0..0"); + URI_TEST_IP_FOUR_FAIL(".0.0.0"); + + URI_TEST_IP_FOUR_PASS("255.0.0.0"); + URI_TEST_IP_FOUR_PASS("0.0.0.0"); + URI_TEST_IP_FOUR_PASS("1.0.0.0"); + URI_TEST_IP_FOUR_PASS("2.0.0.0"); + URI_TEST_IP_FOUR_PASS("3.0.0.0"); + URI_TEST_IP_FOUR_PASS("30.0.0.0"); +} + +TEST(UriSuite, TestIpSixPass) { + // Quad length + URI_TEST_IP_SIX_PASS("abcd::"); + + URI_TEST_IP_SIX_PASS("abcd::1"); + URI_TEST_IP_SIX_PASS("abcd::12"); + URI_TEST_IP_SIX_PASS("abcd::123"); + URI_TEST_IP_SIX_PASS("abcd::1234"); + + // Full length + URI_TEST_IP_SIX_PASS("2001:0db8:0100:f101:0210:a4ff:fee3:9566"); // lower hex + URI_TEST_IP_SIX_PASS("2001:0DB8:0100:F101:0210:A4FF:FEE3:9566"); // Upper hex + URI_TEST_IP_SIX_PASS("2001:db8:100:f101:210:a4ff:fee3:9566"); + URI_TEST_IP_SIX_PASS("2001:0db8:100:f101:0:0:0:1"); + URI_TEST_IP_SIX_PASS("1:2:3:4:5:6:255.255.255.255"); + + // Legal IPv4 + URI_TEST_IP_SIX_PASS("::1.2.3.4"); + URI_TEST_IP_SIX_PASS("3:4::5:1.2.3.4"); + URI_TEST_IP_SIX_PASS("::ffff:1.2.3.4"); + URI_TEST_IP_SIX_PASS("::0.0.0.0"); // Min IPv4 + URI_TEST_IP_SIX_PASS("::255.255.255.255"); // Max IPv4 + + // Zipper position + URI_TEST_IP_SIX_PASS("::1:2:3:4:5:6:7"); + URI_TEST_IP_SIX_PASS("1::1:2:3:4:5:6"); + URI_TEST_IP_SIX_PASS("1:2::1:2:3:4:5"); + URI_TEST_IP_SIX_PASS("1:2:3::1:2:3:4"); + URI_TEST_IP_SIX_PASS("1:2:3:4::1:2:3"); + URI_TEST_IP_SIX_PASS("1:2:3:4:5::1:2"); + URI_TEST_IP_SIX_PASS("1:2:3:4:5:6::1"); + URI_TEST_IP_SIX_PASS("1:2:3:4:5:6:7::"); + + // Zipper length + URI_TEST_IP_SIX_PASS("1:1:1::1:1:1:1"); + URI_TEST_IP_SIX_PASS("1:1:1::1:1:1"); + URI_TEST_IP_SIX_PASS("1:1:1::1:1"); + URI_TEST_IP_SIX_PASS("1:1::1:1"); + URI_TEST_IP_SIX_PASS("1:1::1"); + URI_TEST_IP_SIX_PASS("1::1"); + URI_TEST_IP_SIX_PASS("::1"); // == localhost + URI_TEST_IP_SIX_PASS("::"); // == all addresses + + // A few more variations + URI_TEST_IP_SIX_PASS("21ff:abcd::1"); + URI_TEST_IP_SIX_PASS("2001:db8:100:f101::1"); + URI_TEST_IP_SIX_PASS("a:b:c::12:1"); + URI_TEST_IP_SIX_PASS("a:b::0:1:2:3"); +} + +TEST(UriSuite, TestIpSixFail) { + // 5 char quad + URI_TEST_IP_SIX_FAIL("::12345"); + + // Two zippers + URI_TEST_IP_SIX_FAIL("abcd::abcd::abcd"); + + // Triple-colon zipper + URI_TEST_IP_SIX_FAIL(":::1234"); + URI_TEST_IP_SIX_FAIL("1234:::1234:1234"); + URI_TEST_IP_SIX_FAIL("1234:1234:::1234"); + URI_TEST_IP_SIX_FAIL("1234:::"); + + // No quads, just IPv4 + URI_TEST_IP_SIX_FAIL("1.2.3.4"); + URI_TEST_IP_SIX_FAIL("0001.0002.0003.0004"); + + // Five quads + URI_TEST_IP_SIX_FAIL("0000:0000:0000:0000:0000:1.2.3.4"); + + // Seven quads + URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0"); + URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0:"); + URI_TEST_IP_SIX_FAIL("0:0:0:0:0:0:0:1.2.3.4"); + + // Nine quads (or more) + URI_TEST_IP_SIX_FAIL("1:2:3:4:5:6:7:8:9"); + URI_TEST_IP_SIX_FAIL("::2:3:4:5:6:7:8:9"); + URI_TEST_IP_SIX_FAIL("1:2:3:4::6:7:8:9"); + URI_TEST_IP_SIX_FAIL("1:2:3:4:5:6:7:8::"); + + // Invalid IPv4 part + URI_TEST_IP_SIX_FAIL("::ffff:001.02.03.004"); // Leading zeros + URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.1111"); // Four char octet + URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.256"); // > 255 + URI_TEST_IP_SIX_FAIL("::ffff:311.2.3.4"); // > 155 + URI_TEST_IP_SIX_FAIL("::ffff:1.2.3:4"); // Not a dot + URI_TEST_IP_SIX_FAIL("::ffff:1.2.3"); // Missing octet + URI_TEST_IP_SIX_FAIL("::ffff:1.2.3."); // Missing octet + URI_TEST_IP_SIX_FAIL("::ffff:1.2.3a.4"); // Hex in octet + URI_TEST_IP_SIX_FAIL("::ffff:1.2.3.4:123"); // Crap input + + // Nonhex + URI_TEST_IP_SIX_FAIL("g:0:0:0:0:0:0"); +} + +TEST(UriSuite, TestIpSixOverread) { + UriUriA uri; + const char * errorPos; + + // NOTE: This string is designed to not have a terminator + char uriText[2 + 3 + 2 + 1 + 1]; memcpy(uriText, "//[::44.1", sizeof(uriText)); - - EXPECT_EQ(uriParseSingleUriExA(&uri, uriText, - uriText + sizeof(uriText), &errorPos), URI_ERROR_SYNTAX); - EXPECT_EQ(errorPos, uriText + sizeof(uriText)); -} - -TEST(UriSuite, TestUri) { - UriParserStateA stateA; - UriParserStateW stateW; - UriUriA uriA; - UriUriW uriW; - - stateA.uri = &uriA; - stateW.uri = &uriW; - - // On/off for each - ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@[::1]:80/segment/index.html?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://[::1]:80/segment/index.html?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]/segment/index.html?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80?query#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html#frag")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html?query")); - uriFreeUriMembersA(&uriA); - - // Schema, port, one segment - ASSERT_TRUE(0 == uriParseUriA(&stateA, "ftp://host:21/gnu/")); - uriFreeUriMembersA(&uriA); - - // Relative - ASSERT_TRUE(0 == uriParseUriA(&stateA, "one/two/three")); - ASSERT_TRUE(!uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "/one/two/three")); - ASSERT_TRUE(uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@localhost/one/two/three")); - uriFreeUriMembersA(&uriA); - + + EXPECT_EQ(uriParseSingleUriExA(&uri, uriText, + uriText + sizeof(uriText), &errorPos), URI_ERROR_SYNTAX); + EXPECT_EQ(errorPos, uriText + sizeof(uriText)); +} + +TEST(UriSuite, TestUri) { + UriParserStateA stateA; + UriParserStateW stateW; + UriUriA uriA; + UriUriW uriW; + + stateA.uri = &uriA; + stateW.uri = &uriW; + + // On/off for each + ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@[::1]:80/segment/index.html?query#frag")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://[::1]:80/segment/index.html?query#frag")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]/segment/index.html?query#frag")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80?query#frag")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html#frag")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html?query")); + uriFreeUriMembersA(&uriA); + + // Schema, port, one segment + ASSERT_TRUE(0 == uriParseUriA(&stateA, "ftp://host:21/gnu/")); + uriFreeUriMembersA(&uriA); + + // Relative + ASSERT_TRUE(0 == uriParseUriA(&stateA, "one/two/three")); + ASSERT_TRUE(!uriA.absolutePath); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "/one/two/three")); + ASSERT_TRUE(uriA.absolutePath); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@localhost/one/two/three")); + uriFreeUriMembersA(&uriA); + // Both narrow and wide string version - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriW(&stateW, L"http://www.example.com/")); - uriFreeUriMembersW(&uriW); - - // Real life examples - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://sourceforge.net/projects/uriparser/")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://sourceforge.net/project/platformdownload.php?group_id=182840")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "mailto:test@example.com")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "../../")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "/")); - ASSERT_TRUE(uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "")); - ASSERT_TRUE(!uriA.absolutePath); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 == uriParseUriA(&stateA, "file:///bin/bash")); - uriFreeUriMembersA(&uriA); - - // Percent encoding - ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/name%20with%20spaces/")); - uriFreeUriMembersA(&uriA); - ASSERT_TRUE(0 != uriParseUriA(&stateA, "http://www.example.com/name with spaces/")); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriComponents) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 15 01 0 7 01 - const char * const input = "http" "://" "sourceforge.net" "/" "project" "/" - // 0 20 01 0 15 - "platformdownload.php" "?" "group_id=182840"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.scheme.first == input); - ASSERT_TRUE(uriA.scheme.afterLast == input + 4); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 15); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - - ASSERT_TRUE(uriA.pathHead->text.first == input + 4 + 3 + 15 + 1); - ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 4 + 3 + 15 + 1 + 7); - ASSERT_TRUE(uriA.pathHead->next->text.first == input + 4 + 3 + 15 + 1 + 7 + 1); - ASSERT_TRUE(uriA.pathHead->next->text.afterLast == input + 4 + 3 + 15 + 1 + 7 + 1 + 20); - ASSERT_TRUE(uriA.pathHead->next->next == NULL); - ASSERT_TRUE(uriA.pathTail == uriA.pathHead->next); - - ASSERT_TRUE(uriA.query.first == input + 4 + 3 + 15 + 1 + 7 + 1 + 20 + 1); - ASSERT_TRUE(uriA.query.afterLast == input + 4 + 3 + 15 + 1 + 7 + 1 + 20 + 1 + 15); - ASSERT_TRUE(uriA.fragment.first == NULL); - ASSERT_TRUE(uriA.fragment.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriComponentsBug20070701) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 01 01 01 - const char * const input = "a" ":" "b"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.scheme.first == input); - ASSERT_TRUE(uriA.scheme.afterLast == input + 1); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == NULL); - ASSERT_TRUE(uriA.hostText.afterLast == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - - ASSERT_TRUE(uriA.pathHead->text.first == input + 1 + 1); - ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 1 + 1 + 1); - ASSERT_TRUE(uriA.pathHead->next == NULL); - ASSERT_TRUE(uriA.pathTail == uriA.pathHead); - - ASSERT_TRUE(uriA.query.first == NULL); - ASSERT_TRUE(uriA.query.afterLast == NULL); - ASSERT_TRUE(uriA.fragment.first == NULL); - ASSERT_TRUE(uriA.fragment.afterLast == NULL); - - ASSERT_TRUE(!uriA.absolutePath); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort1) { - // User info with ":", no port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abc:def" "@" "localhost"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort2) { - // User info with ":", with port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abc:def" "@" "localhost" - // 01 0 3 - ":" "123"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 7 + 1 + 9 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 7 + 1 + 9 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort22Bug1948038) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - - res = uriParseUriA(&stateA, "http://user:21@host/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:21", 7 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 7); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); - - res = uriParseUriA(&stateA, "http://user:1234@192.168.0.1:1234/foo.com"); - ASSERT_TRUE(URI_SUCCESS == res); - uriFreeUriMembersA(&uriA); - - res = uriParseUriA(&stateA, "http://moo:21@moo:21@moo/"); - ASSERT_TRUE(URI_ERROR_SYNTAX == res); - uriFreeUriMembersA(&uriA); - - res = uriParseUriA(&stateA, "http://moo:21@moo:21@moo:21/"); - ASSERT_TRUE(URI_ERROR_SYNTAX == res); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198One) { - // User info with ":", with port, with escaped chars in password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 10 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "user:%2F21" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:%2F21", 10 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 10); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Two) { - // User info with ":", with port, with escaped chars in user name and password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 13 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "%2Fuser:%2F21" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "%2Fuser:%2F21", 13 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 13); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Three) { - // User info with ":", with port, with escaped chars in password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 16 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "user:!$&'()*+,;=" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:!$&'()*+,;=", 16 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 16); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Four) { - // User info with ":", with port, with escaped chars in user name and password - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 20 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "!$&'()*+,;=:password" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "!$&'()*+,;=:password", 20 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 20); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedOne) { - // Empty user info - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(uriA.userInfo.afterLast != NULL); - ASSERT_TRUE(uriA.userInfo.first != NULL); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 0); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedOneTwo) { - // Empty user info - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 7 01 - res = uriParseUriA(&stateA, "http" "://" "%2Fhost" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "%2Fhost", 7 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 7); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedTwo) { - // Several colons in userinfo - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - - int res; - // 0 4 0 3 0 2 01 0 4 01 - res = uriParseUriA(&stateA, "http" "://" "::" "@" "host" "/"); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(!memcmp(uriA.userInfo.first, "::", 2 * sizeof(char))); - ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 2); - ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort3) { - // User info without ":", no port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abcdefg" "@" "localhost"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort4) { - // User info without ":", with port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 9 - const char * const input = "http" "://" "abcdefg" "@" "localhost" - // 01 0 3 - ":" "123"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); - ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 7 + 1 + 9 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 7 + 1 + 9 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort5) { - // No user info, no port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 9 - const char * const input = "http" "://" "localhost"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 9); - ASSERT_TRUE(uriA.portText.first == NULL); - ASSERT_TRUE(uriA.portText.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriUserInfoHostPort6) { - // No user info, with port - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 9 01 0 3 - const char * const input = "http" "://" "localhost" ":" "123"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 9); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 9 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 9 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostRegname) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 11 - const char * const input = "http" "://" "example.com"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 11); - ASSERT_TRUE(uriA.hostData.ip4 == NULL); - ASSERT_TRUE(uriA.hostData.ip6 == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpFour1) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 01 0 2 - const char * const input = "http" "://" "1.2.3.4" ":" "80"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostData.ip4 != NULL); - ASSERT_TRUE(uriA.hostData.ip6 == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpFour2) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 0 7 - const char * const input = "http" "://" "1.2.3.4"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7); - ASSERT_TRUE(uriA.hostData.ip4 != NULL); - ASSERT_TRUE(uriA.hostData.ip6 == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpSix1) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 01 45 01 0 2 - const char * const input = "http" "://" "[::1]" ":" "80"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 4); - ASSERT_TRUE(uriA.hostData.ip4 == NULL); - ASSERT_TRUE(uriA.hostData.ip6 != NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpSix2) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 01 45 - const char * const input = "http" "://" "[::1]"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 1); - ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 4); - ASSERT_TRUE(uriA.hostData.ip4 == NULL); - ASSERT_TRUE(uriA.hostData.ip6 != NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); - ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostEmpty) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 4 0 3 01 0 3 - const char * const input = "http" "://" ":" "123"; - const int res = uriParseUriA(&stateA, input); - ASSERT_TRUE(URI_SUCCESS == res); - ASSERT_TRUE(uriA.userInfo.first == NULL); - ASSERT_TRUE(uriA.userInfo.afterLast == NULL); - ASSERT_TRUE(uriA.hostText.first != NULL); - ASSERT_TRUE(uriA.hostText.afterLast != NULL); - ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 0); - ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 1); - ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 1 + 3); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestUriHostIpFuture) { - // TODO -} - -namespace { - bool testEscapingHelper(const wchar_t * in, const wchar_t * expectedOut, - bool spaceToPlus = false, bool normalizeBreaks = false) { - wchar_t * const buffer = new wchar_t[(normalizeBreaks ? 6 : 3) - * wcslen(in) + 1]; - if (uriEscapeW(in, buffer, spaceToPlus, normalizeBreaks) - != buffer + wcslen(expectedOut)) { - delete [] buffer; - return false; - } - - const bool equal = !wcscmp(buffer, expectedOut); - delete [] buffer; - return equal; - } -} // namespace - -TEST(UriSuite, TestEscaping) { - const bool SPACE_TO_PLUS = true; - const bool SPACE_TO_PERCENT = false; - const bool KEEP_UNMODIFIED = false; - const bool NORMALIZE = true; - - // '+' to ' ' - ASSERT_TRUE(testEscapingHelper(L"abc def", L"abc+def", SPACE_TO_PLUS)); - ASSERT_TRUE(testEscapingHelper(L"abc def", L"abc%20def", SPACE_TO_PERCENT)); - - // Percent encoding - ASSERT_TRUE(testEscapingHelper(L"\x00", L"\0")); - ASSERT_TRUE(testEscapingHelper(L"\x01", L"%01")); - ASSERT_TRUE(testEscapingHelper(L"\xff", L"%FF")); - - // Linebreak normalization - ASSERT_TRUE(testEscapingHelper(L"\x0d", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0dg", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0d", L"%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d", L"g%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0dg", L"%0Dg", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - - ASSERT_TRUE(testEscapingHelper(L"\x0a", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0a", L"%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a", L"g%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0ag", L"%0Ag", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0a", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d\x0a", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0a", L"%0D%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0d\x0a", L"g%0D%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0d\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0d", L"%0D%0A%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a\x0d", L"g%0D%0A%0D%0A", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0dg", L"%0D%0A%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0d", L"%0A%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"g\x0a\x0d", L"g%0A%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); - ASSERT_TRUE(testEscapingHelper(L"\x0a\x0dg", L"%0A%0Dg", SPACE_TO_PLUS, KEEP_UNMODIFIED)); -} - -namespace { - bool testUnescapingHelper(const wchar_t * input, const wchar_t * output, - bool plusToSpace = false, UriBreakConversion breakConversion = URI_BR_DONT_TOUCH) { - wchar_t * working = new wchar_t[URI_STRLEN(input) + 1]; - wcscpy(working, input); - const wchar_t * newTermZero = uriUnescapeInPlaceExW(working, - plusToSpace ? URI_TRUE : URI_FALSE, breakConversion); - const bool success = ((newTermZero == working + wcslen(output)) - && !wcscmp(working, output)); - delete[] working; - return success; - } -} // namespace - -TEST(UriSuite, TestUnescaping) { - const bool PLUS_TO_SPACE = true; - const bool PLUS_DONT_TOUCH = false; - - - // Proper - ASSERT_TRUE(testUnescapingHelper(L"abc%20%41BC", L"abc ABC")); - ASSERT_TRUE(testUnescapingHelper(L"%20", L" ")); - - // Incomplete - ASSERT_TRUE(testUnescapingHelper(L"%0", L"%0")); - - // Nonhex - ASSERT_TRUE(testUnescapingHelper(L"%0g", L"%0g")); - ASSERT_TRUE(testUnescapingHelper(L"%G0", L"%G0")); - - // No double decoding - ASSERT_TRUE(testUnescapingHelper(L"%2520", L"%20")); - - // Decoding of '+' - ASSERT_TRUE(testUnescapingHelper(L"abc+def", L"abc+def", PLUS_DONT_TOUCH)); - ASSERT_TRUE(testUnescapingHelper(L"abc+def", L"abc def", PLUS_TO_SPACE)); - - // Line break conversion - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0a\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0d\x0a\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0d\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0a\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); - - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0a\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0d\x0a\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0d\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); - ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0a\x0d\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); -} - -namespace { - bool testAddBaseHelper(const wchar_t * base, const wchar_t * rel, const wchar_t * expectedResult, bool backward_compatibility = false) { - UriParserStateW stateW; - - // Base - UriUriW baseUri; - stateW.uri = &baseUri; - int res = uriParseUriW(&stateW, base); - if (res != 0) { - uriFreeUriMembersW(&baseUri); - return false; - } - - // Rel - UriUriW relUri; - stateW.uri = &relUri; - res = uriParseUriW(&stateW, rel); - if (res != 0) { - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - return false; - } - - // Expected result - UriUriW expectedUri; - stateW.uri = &expectedUri; - res = uriParseUriW(&stateW, expectedResult); - if (res != 0) { - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - // Transform - UriUriW transformedUri; - if (backward_compatibility) { - res = uriAddBaseUriExW(&transformedUri, &relUri, &baseUri, URI_RESOLVE_IDENTICAL_SCHEME_COMPAT); - } else { - res = uriAddBaseUriW(&transformedUri, &relUri, &baseUri); - } - - if (res != 0) { - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - uriFreeUriMembersW(&expectedUri); - uriFreeUriMembersW(&transformedUri); - return false; - } - - const bool equal = (URI_TRUE == uriEqualsUriW(&transformedUri, &expectedUri)); - if (!equal) { - wchar_t transformedUriText[1024 * 8]; - wchar_t expectedUriText[1024 * 8]; - uriToStringW(transformedUriText, &transformedUri, 1024 * 8, NULL); - uriToStringW(expectedUriText, &expectedUri, 1024 * 8, NULL); -#ifdef HAVE_WPRINTF - wprintf(L"\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", expectedUriText, transformedUriText); -#endif - } - - uriFreeUriMembersW(&baseUri); - uriFreeUriMembersW(&relUri); - uriFreeUriMembersW(&expectedUri); - uriFreeUriMembersW(&transformedUri); - return equal; - } -} // namespace - -TEST(UriSuite, TestTrailingSlash) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - // 0 3 01 - const char * const input = "abc" "/"; - ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); - - ASSERT_TRUE(uriA.pathHead->text.first == input); - ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 3); - ASSERT_TRUE(uriA.pathHead->next->text.first == uriA.pathHead->next->text.afterLast); - ASSERT_TRUE(uriA.pathHead->next->next == NULL); - ASSERT_TRUE(uriA.pathTail == uriA.pathHead->next); - uriFreeUriMembersA(&uriA); -} - -TEST(UriSuite, TestAddBase) { - // 5.4.1. Normal Examples - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g:h", L"g:h")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g", L"http://a/b/c/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./g", L"http://a/b/c/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/", L"http://a/b/c/g/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"//g", L"http://g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"?y", L"http://a/b/c/d;p?y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y", L"http://a/b/c/g?y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"#s", L"http://a/b/c/d;p?q#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s", L"http://a/b/c/g#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y#s", L"http://a/b/c/g?y#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L";x", L"http://a/b/c/;x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x", L"http://a/b/c/g;x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x?y#s", L"http://a/b/c/g;x?y#s")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"", L"http://a/b/c/d;p?q")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L".", L"http://a/b/c/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./", L"http://a/b/c/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"..", L"http://a/b/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../", L"http://a/b/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../g", L"http://a/b/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../..", L"http://a/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../", L"http://a/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../g", L"http://a/g")); - - // 5.4.2. Abnormal Examples - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../../g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/./g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/../g", L"http://a/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g.", L"http://a/b/c/g.")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L".g", L"http://a/b/c/.g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g..", L"http://a/b/c/g..")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"..g", L"http://a/b/c/..g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./../g", L"http://a/b/g")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./g/.", L"http://a/b/c/g/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/./h", L"http://a/b/c/g/h")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/../h", L"http://a/b/c/h")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x=1/./y", L"http://a/b/c/g;x=1/y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x=1/../y", L"http://a/b/c/y")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y/./x", L"http://a/b/c/g?y/./x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y/../x", L"http://a/b/c/g?y/../x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s/./x", L"http://a/b/c/g#s/./x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s/../x", L"http://a/b/c/g#s/../x")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http:g")); - - // Backward compatibility (feature request #4, RFC3986 5.4.2) - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http:g", false)); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http://a/b/c/g", true)); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g?q#f", L"http://a/b/c/g?q#f", true)); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"other:g?q#f", L"other:g?q#f", true)); - - // Bug related to absolutePath flag set despite presence of host - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/", L"http://a/")); - ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g/", L"http://a/g/")); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriW(&stateW, L"http://www.example.com/")); + uriFreeUriMembersW(&uriW); + + // Real life examples + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://sourceforge.net/projects/uriparser/")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://sourceforge.net/project/platformdownload.php?group_id=182840")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "mailto:test@example.com")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "../../")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "/")); + ASSERT_TRUE(uriA.absolutePath); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "")); + ASSERT_TRUE(!uriA.absolutePath); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 == uriParseUriA(&stateA, "file:///bin/bash")); + uriFreeUriMembersA(&uriA); + + // Percent encoding + ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/name%20with%20spaces/")); + uriFreeUriMembersA(&uriA); + ASSERT_TRUE(0 != uriParseUriA(&stateA, "http://www.example.com/name with spaces/")); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriComponents) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 15 01 0 7 01 + const char * const input = "http" "://" "sourceforge.net" "/" "project" "/" + // 0 20 01 0 15 + "platformdownload.php" "?" "group_id=182840"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.scheme.first == input); + ASSERT_TRUE(uriA.scheme.afterLast == input + 4); + ASSERT_TRUE(uriA.userInfo.first == NULL); + ASSERT_TRUE(uriA.userInfo.afterLast == NULL); + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 15); + ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + + ASSERT_TRUE(uriA.pathHead->text.first == input + 4 + 3 + 15 + 1); + ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 4 + 3 + 15 + 1 + 7); + ASSERT_TRUE(uriA.pathHead->next->text.first == input + 4 + 3 + 15 + 1 + 7 + 1); + ASSERT_TRUE(uriA.pathHead->next->text.afterLast == input + 4 + 3 + 15 + 1 + 7 + 1 + 20); + ASSERT_TRUE(uriA.pathHead->next->next == NULL); + ASSERT_TRUE(uriA.pathTail == uriA.pathHead->next); + + ASSERT_TRUE(uriA.query.first == input + 4 + 3 + 15 + 1 + 7 + 1 + 20 + 1); + ASSERT_TRUE(uriA.query.afterLast == input + 4 + 3 + 15 + 1 + 7 + 1 + 20 + 1 + 15); + ASSERT_TRUE(uriA.fragment.first == NULL); + ASSERT_TRUE(uriA.fragment.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriComponentsBug20070701) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 01 01 01 + const char * const input = "a" ":" "b"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.scheme.first == input); + ASSERT_TRUE(uriA.scheme.afterLast == input + 1); + ASSERT_TRUE(uriA.userInfo.first == NULL); + ASSERT_TRUE(uriA.userInfo.afterLast == NULL); + ASSERT_TRUE(uriA.hostText.first == NULL); + ASSERT_TRUE(uriA.hostText.afterLast == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + + ASSERT_TRUE(uriA.pathHead->text.first == input + 1 + 1); + ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 1 + 1 + 1); + ASSERT_TRUE(uriA.pathHead->next == NULL); + ASSERT_TRUE(uriA.pathTail == uriA.pathHead); + + ASSERT_TRUE(uriA.query.first == NULL); + ASSERT_TRUE(uriA.query.afterLast == NULL); + ASSERT_TRUE(uriA.fragment.first == NULL); + ASSERT_TRUE(uriA.fragment.afterLast == NULL); + + ASSERT_TRUE(!uriA.absolutePath); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort1) { + // User info with ":", no port + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 7 01 0 9 + const char * const input = "http" "://" "abc:def" "@" "localhost"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); + ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort2) { + // User info with ":", with port + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 7 01 0 9 + const char * const input = "http" "://" "abc:def" "@" "localhost" + // 01 0 3 + ":" "123"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); + ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); + ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 7 + 1 + 9 + 1); + ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 7 + 1 + 9 + 1 + 3); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort22Bug1948038) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + + res = uriParseUriA(&stateA, "http://user:21@host/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:21", 7 * sizeof(char))); + ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 7); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); + + res = uriParseUriA(&stateA, "http://user:1234@192.168.0.1:1234/foo.com"); + ASSERT_TRUE(URI_SUCCESS == res); + uriFreeUriMembersA(&uriA); + + res = uriParseUriA(&stateA, "http://moo:21@moo:21@moo/"); + ASSERT_TRUE(URI_ERROR_SYNTAX == res); + uriFreeUriMembersA(&uriA); + + res = uriParseUriA(&stateA, "http://moo:21@moo:21@moo:21/"); + ASSERT_TRUE(URI_ERROR_SYNTAX == res); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198One) { + // User info with ":", with port, with escaped chars in password + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + // 0 4 0 3 0 10 01 0 4 01 + res = uriParseUriA(&stateA, "http" "://" "user:%2F21" "@" "host" "/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:%2F21", 10 * sizeof(char))); + ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 10); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Two) { + // User info with ":", with port, with escaped chars in user name and password + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + // 0 4 0 3 0 13 01 0 4 01 + res = uriParseUriA(&stateA, "http" "://" "%2Fuser:%2F21" "@" "host" "/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(!memcmp(uriA.userInfo.first, "%2Fuser:%2F21", 13 * sizeof(char))); + ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 13); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Three) { + // User info with ":", with port, with escaped chars in password + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + // 0 4 0 3 0 16 01 0 4 01 + res = uriParseUriA(&stateA, "http" "://" "user:!$&'()*+,;=" "@" "host" "/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(!memcmp(uriA.userInfo.first, "user:!$&'()*+,;=", 16 * sizeof(char))); + ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 16); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198Four) { + // User info with ":", with port, with escaped chars in user name and password + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + // 0 4 0 3 0 20 01 0 4 01 + res = uriParseUriA(&stateA, "http" "://" "!$&'()*+,;=:password" "@" "host" "/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(!memcmp(uriA.userInfo.first, "!$&'()*+,;=:password", 20 * sizeof(char))); + ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 20); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedOne) { + // Empty user info + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + // 0 4 0 3 01 0 4 01 + res = uriParseUriA(&stateA, "http" "://" "@" "host" "/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(uriA.userInfo.afterLast != NULL); + ASSERT_TRUE(uriA.userInfo.first != NULL); + ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 0); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedOneTwo) { + // Empty user info + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + // 0 4 0 3 0 7 01 + res = uriParseUriA(&stateA, "http" "://" "%2Fhost" "/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(uriA.userInfo.afterLast == NULL); + ASSERT_TRUE(uriA.userInfo.first == NULL); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "%2Fhost", 7 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 7); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort23Bug3510198RelatedTwo) { + // Several colons in userinfo + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + + int res; + // 0 4 0 3 0 2 01 0 4 01 + res = uriParseUriA(&stateA, "http" "://" "::" "@" "host" "/"); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(!memcmp(uriA.userInfo.first, "::", 2 * sizeof(char))); + ASSERT_TRUE(uriA.userInfo.afterLast - uriA.userInfo.first == 2); + ASSERT_TRUE(!memcmp(uriA.hostText.first, "host", 4 * sizeof(char))); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 4); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort3) { + // User info without ":", no port + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 7 01 0 9 + const char * const input = "http" "://" "abcdefg" "@" "localhost"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); + ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort4) { + // User info without ":", with port + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 7 01 0 9 + const char * const input = "http" "://" "abcdefg" "@" "localhost" + // 01 0 3 + ":" "123"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); + ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); + ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 7 + 1 + 9 + 1); + ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 7 + 1 + 9 + 1 + 3); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort5) { + // No user info, no port + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 9 + const char * const input = "http" "://" "localhost"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.userInfo.first == NULL); + ASSERT_TRUE(uriA.userInfo.afterLast == NULL); + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 9); + ASSERT_TRUE(uriA.portText.first == NULL); + ASSERT_TRUE(uriA.portText.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriUserInfoHostPort6) { + // No user info, with port + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 9 01 0 3 + const char * const input = "http" "://" "localhost" ":" "123"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.userInfo.first == NULL); + ASSERT_TRUE(uriA.userInfo.afterLast == NULL); + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 9); + ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 9 + 1); + ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 9 + 1 + 3); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriHostRegname) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 11 + const char * const input = "http" "://" "example.com"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 11); + ASSERT_TRUE(uriA.hostData.ip4 == NULL); + ASSERT_TRUE(uriA.hostData.ip6 == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriHostIpFour1) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 7 01 0 2 + const char * const input = "http" "://" "1.2.3.4" ":" "80"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7); + ASSERT_TRUE(uriA.hostData.ip4 != NULL); + ASSERT_TRUE(uriA.hostData.ip6 == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriHostIpFour2) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 0 7 + const char * const input = "http" "://" "1.2.3.4"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7); + ASSERT_TRUE(uriA.hostData.ip4 != NULL); + ASSERT_TRUE(uriA.hostData.ip6 == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriHostIpSix1) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 01 45 01 0 2 + const char * const input = "http" "://" "[::1]" ":" "80"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 1); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 4); + ASSERT_TRUE(uriA.hostData.ip4 == NULL); + ASSERT_TRUE(uriA.hostData.ip6 != NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriHostIpSix2) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 01 45 + const char * const input = "http" "://" "[::1]"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 1); + ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 4); + ASSERT_TRUE(uriA.hostData.ip4 == NULL); + ASSERT_TRUE(uriA.hostData.ip6 != NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.first == NULL); + ASSERT_TRUE(uriA.hostData.ipFuture.afterLast == NULL); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriHostEmpty) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 4 0 3 01 0 3 + const char * const input = "http" "://" ":" "123"; + const int res = uriParseUriA(&stateA, input); + ASSERT_TRUE(URI_SUCCESS == res); + ASSERT_TRUE(uriA.userInfo.first == NULL); + ASSERT_TRUE(uriA.userInfo.afterLast == NULL); + ASSERT_TRUE(uriA.hostText.first != NULL); + ASSERT_TRUE(uriA.hostText.afterLast != NULL); + ASSERT_TRUE(uriA.hostText.afterLast - uriA.hostText.first == 0); + ASSERT_TRUE(uriA.portText.first == input + 4 + 3 + 1); + ASSERT_TRUE(uriA.portText.afterLast == input + 4 + 3 + 1 + 3); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestUriHostIpFuture) { + // TODO +} + +namespace { + bool testEscapingHelper(const wchar_t * in, const wchar_t * expectedOut, + bool spaceToPlus = false, bool normalizeBreaks = false) { + wchar_t * const buffer = new wchar_t[(normalizeBreaks ? 6 : 3) + * wcslen(in) + 1]; + if (uriEscapeW(in, buffer, spaceToPlus, normalizeBreaks) + != buffer + wcslen(expectedOut)) { + delete [] buffer; + return false; + } + + const bool equal = !wcscmp(buffer, expectedOut); + delete [] buffer; + return equal; + } +} // namespace + +TEST(UriSuite, TestEscaping) { + const bool SPACE_TO_PLUS = true; + const bool SPACE_TO_PERCENT = false; + const bool KEEP_UNMODIFIED = false; + const bool NORMALIZE = true; + + // '+' to ' ' + ASSERT_TRUE(testEscapingHelper(L"abc def", L"abc+def", SPACE_TO_PLUS)); + ASSERT_TRUE(testEscapingHelper(L"abc def", L"abc%20def", SPACE_TO_PERCENT)); + + // Percent encoding + ASSERT_TRUE(testEscapingHelper(L"\x00", L"\0")); + ASSERT_TRUE(testEscapingHelper(L"\x01", L"%01")); + ASSERT_TRUE(testEscapingHelper(L"\xff", L"%FF")); + + // Linebreak normalization + ASSERT_TRUE(testEscapingHelper(L"\x0d", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"g\x0d", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0dg", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0d", L"%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"g\x0d", L"g%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"\x0dg", L"%0Dg", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + + ASSERT_TRUE(testEscapingHelper(L"\x0a", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"g\x0a", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0a", L"%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"g\x0a", L"g%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"\x0ag", L"%0Ag", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + + ASSERT_TRUE(testEscapingHelper(L"\x0d\x0a", L"%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"g\x0d\x0a", L"g%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0d\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0d\x0a", L"%0D%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"g\x0d\x0a", L"g%0D%0A", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"\x0d\x0ag", L"%0D%0Ag", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + + ASSERT_TRUE(testEscapingHelper(L"\x0a\x0d", L"%0D%0A%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"g\x0a\x0d", L"g%0D%0A%0D%0A", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0a\x0dg", L"%0D%0A%0D%0Ag", SPACE_TO_PLUS, NORMALIZE)); + ASSERT_TRUE(testEscapingHelper(L"\x0a\x0d", L"%0A%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"g\x0a\x0d", L"g%0A%0D", SPACE_TO_PLUS, KEEP_UNMODIFIED)); + ASSERT_TRUE(testEscapingHelper(L"\x0a\x0dg", L"%0A%0Dg", SPACE_TO_PLUS, KEEP_UNMODIFIED)); +} + +namespace { + bool testUnescapingHelper(const wchar_t * input, const wchar_t * output, + bool plusToSpace = false, UriBreakConversion breakConversion = URI_BR_DONT_TOUCH) { + wchar_t * working = new wchar_t[URI_STRLEN(input) + 1]; + wcscpy(working, input); + const wchar_t * newTermZero = uriUnescapeInPlaceExW(working, + plusToSpace ? URI_TRUE : URI_FALSE, breakConversion); + const bool success = ((newTermZero == working + wcslen(output)) + && !wcscmp(working, output)); + delete[] working; + return success; + } +} // namespace + +TEST(UriSuite, TestUnescaping) { + const bool PLUS_TO_SPACE = true; + const bool PLUS_DONT_TOUCH = false; + + + // Proper + ASSERT_TRUE(testUnescapingHelper(L"abc%20%41BC", L"abc ABC")); + ASSERT_TRUE(testUnescapingHelper(L"%20", L" ")); + + // Incomplete + ASSERT_TRUE(testUnescapingHelper(L"%0", L"%0")); + + // Nonhex + ASSERT_TRUE(testUnescapingHelper(L"%0g", L"%0g")); + ASSERT_TRUE(testUnescapingHelper(L"%G0", L"%G0")); + + // No double decoding + ASSERT_TRUE(testUnescapingHelper(L"%2520", L"%20")); + + // Decoding of '+' + ASSERT_TRUE(testUnescapingHelper(L"abc+def", L"abc+def", PLUS_DONT_TOUCH)); + ASSERT_TRUE(testUnescapingHelper(L"abc+def", L"abc def", PLUS_TO_SPACE)); + + // Line break conversion + ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0d", L"\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + + ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a", L"\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0a", L"\x0d\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d", L"\x0d\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0d%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d", L"\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a", L"\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0a\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0d\x0a\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0d\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0d", L"\x0a\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); + + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0a\x0a\x0a", PLUS_DONT_TOUCH, URI_BR_TO_UNIX)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0d\x0a\x0d\x0a\x0d\x0a", PLUS_DONT_TOUCH, URI_BR_TO_WINDOWS)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0d\x0d\x0d", PLUS_DONT_TOUCH, URI_BR_TO_MAC)); + ASSERT_TRUE(testUnescapingHelper(L"%0a%0d%0a%0d", L"\x0a\x0d\x0a\x0d", PLUS_DONT_TOUCH, URI_BR_DONT_TOUCH)); +} + +namespace { + bool testAddBaseHelper(const wchar_t * base, const wchar_t * rel, const wchar_t * expectedResult, bool backward_compatibility = false) { + UriParserStateW stateW; + + // Base + UriUriW baseUri; + stateW.uri = &baseUri; + int res = uriParseUriW(&stateW, base); + if (res != 0) { + uriFreeUriMembersW(&baseUri); + return false; + } + + // Rel + UriUriW relUri; + stateW.uri = &relUri; + res = uriParseUriW(&stateW, rel); + if (res != 0) { + uriFreeUriMembersW(&baseUri); + uriFreeUriMembersW(&relUri); + return false; + } + + // Expected result + UriUriW expectedUri; + stateW.uri = &expectedUri; + res = uriParseUriW(&stateW, expectedResult); + if (res != 0) { + uriFreeUriMembersW(&baseUri); + uriFreeUriMembersW(&relUri); + uriFreeUriMembersW(&expectedUri); + return false; + } + + // Transform + UriUriW transformedUri; + if (backward_compatibility) { + res = uriAddBaseUriExW(&transformedUri, &relUri, &baseUri, URI_RESOLVE_IDENTICAL_SCHEME_COMPAT); + } else { + res = uriAddBaseUriW(&transformedUri, &relUri, &baseUri); + } + + if (res != 0) { + uriFreeUriMembersW(&baseUri); + uriFreeUriMembersW(&relUri); + uriFreeUriMembersW(&expectedUri); + uriFreeUriMembersW(&transformedUri); + return false; + } + + const bool equal = (URI_TRUE == uriEqualsUriW(&transformedUri, &expectedUri)); + if (!equal) { + wchar_t transformedUriText[1024 * 8]; + wchar_t expectedUriText[1024 * 8]; + uriToStringW(transformedUriText, &transformedUri, 1024 * 8, NULL); + uriToStringW(expectedUriText, &expectedUri, 1024 * 8, NULL); +#ifdef HAVE_WPRINTF + wprintf(L"\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", expectedUriText, transformedUriText); +#endif + } + + uriFreeUriMembersW(&baseUri); + uriFreeUriMembersW(&relUri); + uriFreeUriMembersW(&expectedUri); + uriFreeUriMembersW(&transformedUri); + return equal; + } +} // namespace + +TEST(UriSuite, TestTrailingSlash) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + // 0 3 01 + const char * const input = "abc" "/"; + ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); + + ASSERT_TRUE(uriA.pathHead->text.first == input); + ASSERT_TRUE(uriA.pathHead->text.afterLast == input + 3); + ASSERT_TRUE(uriA.pathHead->next->text.first == uriA.pathHead->next->text.afterLast); + ASSERT_TRUE(uriA.pathHead->next->next == NULL); + ASSERT_TRUE(uriA.pathTail == uriA.pathHead->next); + uriFreeUriMembersA(&uriA); +} + +TEST(UriSuite, TestAddBase) { + // 5.4.1. Normal Examples + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g:h", L"g:h")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g", L"http://a/b/c/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./g", L"http://a/b/c/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/", L"http://a/b/c/g/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g", L"http://a/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"//g", L"http://g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"?y", L"http://a/b/c/d;p?y")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y", L"http://a/b/c/g?y")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"#s", L"http://a/b/c/d;p?q#s")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s", L"http://a/b/c/g#s")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y#s", L"http://a/b/c/g?y#s")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L";x", L"http://a/b/c/;x")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x", L"http://a/b/c/g;x")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x?y#s", L"http://a/b/c/g;x?y#s")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"", L"http://a/b/c/d;p?q")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L".", L"http://a/b/c/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./", L"http://a/b/c/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"..", L"http://a/b/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../", L"http://a/b/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../g", L"http://a/b/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../..", L"http://a/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../", L"http://a/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../g", L"http://a/g")); + + // 5.4.2. Abnormal Examples + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../g", L"http://a/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../../g", L"http://a/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/./g", L"http://a/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/../g", L"http://a/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g.", L"http://a/b/c/g.")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L".g", L"http://a/b/c/.g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g..", L"http://a/b/c/g..")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"..g", L"http://a/b/c/..g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./../g", L"http://a/b/g")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"./g/.", L"http://a/b/c/g/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/./h", L"http://a/b/c/g/h")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g/../h", L"http://a/b/c/h")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x=1/./y", L"http://a/b/c/g;x=1/y")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g;x=1/../y", L"http://a/b/c/y")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y/./x", L"http://a/b/c/g?y/./x")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g?y/../x", L"http://a/b/c/g?y/../x")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s/./x", L"http://a/b/c/g#s/./x")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"g#s/../x", L"http://a/b/c/g#s/../x")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http:g")); + + // Backward compatibility (feature request #4, RFC3986 5.4.2) + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http:g", false)); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g", L"http://a/b/c/g", true)); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"http:g?q#f", L"http://a/b/c/g?q#f", true)); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"other:g?q#f", L"other:g?q#f", true)); + + // Bug related to absolutePath flag set despite presence of host + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/", L"http://a/")); + ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g/", L"http://a/g/")); // GitHub issue #92 EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/../d;p?q", L"../..", L"http://a/")); @@ -1111,385 +1111,385 @@ TEST(UriSuite, TestAddBase) { EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../..", L"http://a/")); EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../", L"http://a/")); -} - -namespace { - bool testToStringHelper(const wchar_t * text) { - // Parse - UriParserStateW state; - UriUriW uri; - state.uri = &uri; - int res = uriParseUriW(&state, text); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - // Back to string, _huge_ limit - wchar_t shouldbeTheSame[1024 * 8]; - res = uriToStringW(shouldbeTheSame, &uri, 1024 * 8, NULL); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - // Compare - bool equals = (0 == wcscmp(shouldbeTheSame, text)); - if (!equals) { -#ifdef HAVE_WPRINTF - wprintf(L"\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", text, shouldbeTheSame); -#endif - } - - // Back to string, _exact_ limit - const int len = static_cast<int>(wcslen(text)); - int charsWritten; - res = uriToStringW(shouldbeTheSame, &uri, len + 1, &charsWritten); - if ((res != 0) || (charsWritten != len + 1)) { - uriFreeUriMembersW(&uri); - return false; - } - - // Back to string, _too small_ limit - res = uriToStringW(shouldbeTheSame, &uri, len, &charsWritten); - if ((res == 0) || (charsWritten >= len + 1)) { - uriFreeUriMembersW(&uri); - return false; - } - - uriFreeUriMembersW(&uri); - return equals; - } -} // namespace - -TEST(UriSuite, TestToString) { - // Scheme - ASSERT_TRUE(testToStringHelper(L"ftp://localhost/")); - // UserInfo - ASSERT_TRUE(testToStringHelper(L"http://user:pass@localhost/")); - // IPv4 - ASSERT_TRUE(testToStringHelper(L"http://123.0.1.255/")); - // IPv6 - ASSERT_TRUE(testToStringHelper(L"http://[abcd:abcd:abcd:abcd:abcd:abcd:abcd:abcd]/")); - // IPvFuture - ASSERT_TRUE(testToStringHelper(L"http://[vA.123456]/")); - // Port - ASSERT_TRUE(testToStringHelper(L"http://example.com:123/")); - // Path - ASSERT_TRUE(testToStringHelper(L"http://example.com")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/def")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/def/")); - ASSERT_TRUE(testToStringHelper(L"http://example.com//")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/./..")); - // Query - ASSERT_TRUE(testToStringHelper(L"http://example.com/?abc")); - // Fragment - ASSERT_TRUE(testToStringHelper(L"http://example.com/#abc")); - ASSERT_TRUE(testToStringHelper(L"http://example.com/?def#abc")); - - // Relative - ASSERT_TRUE(testToStringHelper(L"a")); - ASSERT_TRUE(testToStringHelper(L"a/")); - ASSERT_TRUE(testToStringHelper(L"/a")); - ASSERT_TRUE(testToStringHelper(L"/a/")); - ASSERT_TRUE(testToStringHelper(L"abc")); - ASSERT_TRUE(testToStringHelper(L"abc/")); - ASSERT_TRUE(testToStringHelper(L"/abc")); - ASSERT_TRUE(testToStringHelper(L"/abc/")); - ASSERT_TRUE(testToStringHelper(L"a/def")); - ASSERT_TRUE(testToStringHelper(L"a/def/")); - ASSERT_TRUE(testToStringHelper(L"/a/def")); - ASSERT_TRUE(testToStringHelper(L"/a/def/")); - ASSERT_TRUE(testToStringHelper(L"abc/def")); - ASSERT_TRUE(testToStringHelper(L"abc/def/")); - ASSERT_TRUE(testToStringHelper(L"/abc/def")); - ASSERT_TRUE(testToStringHelper(L"/abc/def/")); - ASSERT_TRUE(testToStringHelper(L"/")); - ASSERT_TRUE(testToStringHelper(L"//a/")); - ASSERT_TRUE(testToStringHelper(L".")); - ASSERT_TRUE(testToStringHelper(L"./")); - ASSERT_TRUE(testToStringHelper(L"/.")); - ASSERT_TRUE(testToStringHelper(L"/./")); - ASSERT_TRUE(testToStringHelper(L"")); - ASSERT_TRUE(testToStringHelper(L"./abc/def")); - ASSERT_TRUE(testToStringHelper(L"?query")); - ASSERT_TRUE(testToStringHelper(L"#fragment")); - ASSERT_TRUE(testToStringHelper(L"?query#fragment")); - - // Tests for bugs from the past - ASSERT_TRUE(testToStringHelper(L"f:/.//g")); -} - -TEST(UriSuite, TestToStringBug1950126) { - UriParserStateW state; - UriUriW uriOne; - UriUriW uriTwo; - const wchar_t * const uriOneString = L"http://e.com/"; - const wchar_t * const uriTwoString = L"http://e.com"; - state.uri = &uriOne; - ASSERT_TRUE(URI_SUCCESS == uriParseUriW(&state, uriOneString)); - state.uri = &uriTwo; - ASSERT_TRUE(URI_SUCCESS == uriParseUriW(&state, uriTwoString)); - ASSERT_TRUE(URI_FALSE == uriEqualsUriW(&uriOne, &uriTwo)); - uriFreeUriMembersW(&uriOne); - uriFreeUriMembersW(&uriTwo); - - ASSERT_TRUE(testToStringHelper(uriOneString)); - ASSERT_TRUE(testToStringHelper(uriTwoString)); -} - -namespace { - bool testToStringCharsRequiredHelper(const wchar_t * text) { - // Parse - UriParserStateW state; - UriUriW uri; - state.uri = &uri; - int res = uriParseUriW(&state, text); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - // Required space? - int charsRequired; - if (uriToStringCharsRequiredW(&uri, &charsRequired) != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - EXPECT_EQ(charsRequired, wcslen(text)); - - // Minimum - wchar_t * buffer = new wchar_t[charsRequired + 1]; - if (uriToStringW(buffer, &uri, charsRequired + 1, NULL) != 0) { - uriFreeUriMembersW(&uri); - delete [] buffer; - return false; - } - - // One less than minimum - if (uriToStringW(buffer, &uri, charsRequired, NULL) == 0) { - uriFreeUriMembersW(&uri); - delete [] buffer; - return false; - } - - uriFreeUriMembersW(&uri); - delete [] buffer; - return true; - } -} // namespace - -TEST(UriSuite, TestToStringCharsRequired) { - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://12.1.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://123.1.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.12.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.123.1.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.12.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.123.1/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.12/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.123/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com:80/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://user:pass@www.example.com/")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/index.html")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/#def")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc#def")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"/test")); - EXPECT_TRUE(testToStringCharsRequiredHelper(L"test")); -} - -namespace { - bool testNormalizeMaskHelper(const wchar_t * uriText, unsigned int expectedMask) { - UriParserStateW state; - UriUriW uri; - state.uri = &uri; - int res = uriParseUriW(&state, uriText); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - const unsigned int maskBefore = uriNormalizeSyntaxMaskRequiredW(&uri); - if (maskBefore != expectedMask) { - uriFreeUriMembersW(&uri); - return false; - } - - res = uriNormalizeSyntaxW(&uri); - if (res != 0) { - uriFreeUriMembersW(&uri); - return false; - } - - const unsigned int maskAfter = uriNormalizeSyntaxMaskRequiredW(&uri); - uriFreeUriMembersW(&uri); - - // Second call should be no problem - uriFreeUriMembersW(&uri); - - return (maskAfter == URI_NORMALIZED); - } -} // namespace - -TEST(UriSuite, TestNormalizeSyntaxMaskRequired) { - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/", URI_NORMALIZED)); - ASSERT_TRUE(testNormalizeMaskHelper(L"httP://localhost/", URI_NORMALIZE_SCHEME)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://%0d@localhost/", URI_NORMALIZE_USER_INFO)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhosT/", URI_NORMALIZE_HOST)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/./abc", URI_NORMALIZE_PATH)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/?AB%43", URI_NORMALIZE_QUERY)); - ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/#AB%43", URI_NORMALIZE_FRAGMENT)); -} - -namespace { - bool testNormalizeSyntaxHelper(const wchar_t * uriText, const wchar_t * expectedNormalized, - unsigned int mask = static_cast<unsigned int>(-1)) { - UriParserStateW stateW; - int res; - - UriUriW testUri; - stateW.uri = &testUri; - res = uriParseUriW(&stateW, uriText); - if (res != 0) { - uriFreeUriMembersW(&testUri); - return false; - } - - // Expected result - UriUriW expectedUri; - stateW.uri = &expectedUri; - res = uriParseUriW(&stateW, expectedNormalized); - if (res != 0) { - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - // First run - res = uriNormalizeSyntaxExW(&testUri, mask); - if (res != 0) { - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - bool equalAfter = (URI_TRUE == uriEqualsUriW(&testUri, &expectedUri)); - - // Second run - res = uriNormalizeSyntaxExW(&testUri, mask); - if (res != 0) { - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return false; - } - - equalAfter = equalAfter - && (URI_TRUE == uriEqualsUriW(&testUri, &expectedUri)); - - uriFreeUriMembersW(&testUri); - uriFreeUriMembersW(&expectedUri); - return equalAfter; - } -} // namespace - -TEST(UriSuite, TestNormalizeSyntax) { - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"eXAMPLE://a/./b/../b/%63/%7bfoo%7d", - L"example://a/b/c/%7Bfoo%7D")); - - // Testcase by Adrian Manrique - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"http://examp%4Ce.com/", - L"http://example.com/")); - - // Testcase by Adrian Manrique - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"http://example.com/a/b/%2E%2E/", - L"http://example.com/a/")); - - // Reported by Adrian Manrique - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"http://user:pass@SOMEHOST.COM:123", - L"http://user:pass@somehost.com:123")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://a:b@HOST:123/./1/2/../%41?abc#def", - L"http://a:b@host:123/1/A?abc#def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc", - L"../../abc")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc/..", - L"../../")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc/../def", - L"../../def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"abc/..", - L"")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"abc/../", - L"")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"../../abc/./def", - L"../../abc/def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"./def", - L"def")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"def/.", - L"def/")); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"./abc:def", - L"./abc:def")); -} - -TEST(UriSuite, TestNormalizeSyntaxComponents) { - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"http://%41@EXAMPLE.ORG/../a?%41#%41", - URI_NORMALIZE_SCHEME)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://A@EXAMPLE.ORG/../a?%41#%41", - URI_NORMALIZE_USER_INFO)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@example.org/../a?%41#%41", - URI_NORMALIZE_HOST)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@EXAMPLE.ORG/a?%41#%41", - URI_NORMALIZE_PATH)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@EXAMPLE.ORG/../a?A#%41", - URI_NORMALIZE_QUERY)); - - ASSERT_TRUE(testNormalizeSyntaxHelper( - L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", - L"HTTP://%41@EXAMPLE.ORG/../a?%41#A", - URI_NORMALIZE_FRAGMENT)); -} - +} + +namespace { + bool testToStringHelper(const wchar_t * text) { + // Parse + UriParserStateW state; + UriUriW uri; + state.uri = &uri; + int res = uriParseUriW(&state, text); + if (res != 0) { + uriFreeUriMembersW(&uri); + return false; + } + + // Back to string, _huge_ limit + wchar_t shouldbeTheSame[1024 * 8]; + res = uriToStringW(shouldbeTheSame, &uri, 1024 * 8, NULL); + if (res != 0) { + uriFreeUriMembersW(&uri); + return false; + } + + // Compare + bool equals = (0 == wcscmp(shouldbeTheSame, text)); + if (!equals) { +#ifdef HAVE_WPRINTF + wprintf(L"\n\n\nExpected: \"%s\"\nReceived: \"%s\"\n\n\n", text, shouldbeTheSame); +#endif + } + + // Back to string, _exact_ limit + const int len = static_cast<int>(wcslen(text)); + int charsWritten; + res = uriToStringW(shouldbeTheSame, &uri, len + 1, &charsWritten); + if ((res != 0) || (charsWritten != len + 1)) { + uriFreeUriMembersW(&uri); + return false; + } + + // Back to string, _too small_ limit + res = uriToStringW(shouldbeTheSame, &uri, len, &charsWritten); + if ((res == 0) || (charsWritten >= len + 1)) { + uriFreeUriMembersW(&uri); + return false; + } + + uriFreeUriMembersW(&uri); + return equals; + } +} // namespace + +TEST(UriSuite, TestToString) { + // Scheme + ASSERT_TRUE(testToStringHelper(L"ftp://localhost/")); + // UserInfo + ASSERT_TRUE(testToStringHelper(L"http://user:pass@localhost/")); + // IPv4 + ASSERT_TRUE(testToStringHelper(L"http://123.0.1.255/")); + // IPv6 + ASSERT_TRUE(testToStringHelper(L"http://[abcd:abcd:abcd:abcd:abcd:abcd:abcd:abcd]/")); + // IPvFuture + ASSERT_TRUE(testToStringHelper(L"http://[vA.123456]/")); + // Port + ASSERT_TRUE(testToStringHelper(L"http://example.com:123/")); + // Path + ASSERT_TRUE(testToStringHelper(L"http://example.com")); + ASSERT_TRUE(testToStringHelper(L"http://example.com/")); + ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/")); + ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/def")); + ASSERT_TRUE(testToStringHelper(L"http://example.com/abc/def/")); + ASSERT_TRUE(testToStringHelper(L"http://example.com//")); + ASSERT_TRUE(testToStringHelper(L"http://example.com/./..")); + // Query + ASSERT_TRUE(testToStringHelper(L"http://example.com/?abc")); + // Fragment + ASSERT_TRUE(testToStringHelper(L"http://example.com/#abc")); + ASSERT_TRUE(testToStringHelper(L"http://example.com/?def#abc")); + + // Relative + ASSERT_TRUE(testToStringHelper(L"a")); + ASSERT_TRUE(testToStringHelper(L"a/")); + ASSERT_TRUE(testToStringHelper(L"/a")); + ASSERT_TRUE(testToStringHelper(L"/a/")); + ASSERT_TRUE(testToStringHelper(L"abc")); + ASSERT_TRUE(testToStringHelper(L"abc/")); + ASSERT_TRUE(testToStringHelper(L"/abc")); + ASSERT_TRUE(testToStringHelper(L"/abc/")); + ASSERT_TRUE(testToStringHelper(L"a/def")); + ASSERT_TRUE(testToStringHelper(L"a/def/")); + ASSERT_TRUE(testToStringHelper(L"/a/def")); + ASSERT_TRUE(testToStringHelper(L"/a/def/")); + ASSERT_TRUE(testToStringHelper(L"abc/def")); + ASSERT_TRUE(testToStringHelper(L"abc/def/")); + ASSERT_TRUE(testToStringHelper(L"/abc/def")); + ASSERT_TRUE(testToStringHelper(L"/abc/def/")); + ASSERT_TRUE(testToStringHelper(L"/")); + ASSERT_TRUE(testToStringHelper(L"//a/")); + ASSERT_TRUE(testToStringHelper(L".")); + ASSERT_TRUE(testToStringHelper(L"./")); + ASSERT_TRUE(testToStringHelper(L"/.")); + ASSERT_TRUE(testToStringHelper(L"/./")); + ASSERT_TRUE(testToStringHelper(L"")); + ASSERT_TRUE(testToStringHelper(L"./abc/def")); + ASSERT_TRUE(testToStringHelper(L"?query")); + ASSERT_TRUE(testToStringHelper(L"#fragment")); + ASSERT_TRUE(testToStringHelper(L"?query#fragment")); + + // Tests for bugs from the past + ASSERT_TRUE(testToStringHelper(L"f:/.//g")); +} + +TEST(UriSuite, TestToStringBug1950126) { + UriParserStateW state; + UriUriW uriOne; + UriUriW uriTwo; + const wchar_t * const uriOneString = L"http://e.com/"; + const wchar_t * const uriTwoString = L"http://e.com"; + state.uri = &uriOne; + ASSERT_TRUE(URI_SUCCESS == uriParseUriW(&state, uriOneString)); + state.uri = &uriTwo; + ASSERT_TRUE(URI_SUCCESS == uriParseUriW(&state, uriTwoString)); + ASSERT_TRUE(URI_FALSE == uriEqualsUriW(&uriOne, &uriTwo)); + uriFreeUriMembersW(&uriOne); + uriFreeUriMembersW(&uriTwo); + + ASSERT_TRUE(testToStringHelper(uriOneString)); + ASSERT_TRUE(testToStringHelper(uriTwoString)); +} + +namespace { + bool testToStringCharsRequiredHelper(const wchar_t * text) { + // Parse + UriParserStateW state; + UriUriW uri; + state.uri = &uri; + int res = uriParseUriW(&state, text); + if (res != 0) { + uriFreeUriMembersW(&uri); + return false; + } + + // Required space? + int charsRequired; + if (uriToStringCharsRequiredW(&uri, &charsRequired) != 0) { + uriFreeUriMembersW(&uri); + return false; + } + + EXPECT_EQ(charsRequired, wcslen(text)); + + // Minimum + wchar_t * buffer = new wchar_t[charsRequired + 1]; + if (uriToStringW(buffer, &uri, charsRequired + 1, NULL) != 0) { + uriFreeUriMembersW(&uri); + delete [] buffer; + return false; + } + + // One less than minimum + if (uriToStringW(buffer, &uri, charsRequired, NULL) == 0) { + uriFreeUriMembersW(&uri); + delete [] buffer; + return false; + } + + uriFreeUriMembersW(&uri); + delete [] buffer; + return true; + } +} // namespace + +TEST(UriSuite, TestToStringCharsRequired) { + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.1/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://12.1.1.1/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://123.1.1.1/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.12.1.1/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.123.1.1/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.12.1/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.123.1/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.12/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.123/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com:80/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://user:pass@www.example.com/")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/index.html")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/#def")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc#def")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"/test")); + EXPECT_TRUE(testToStringCharsRequiredHelper(L"test")); +} + +namespace { + bool testNormalizeMaskHelper(const wchar_t * uriText, unsigned int expectedMask) { + UriParserStateW state; + UriUriW uri; + state.uri = &uri; + int res = uriParseUriW(&state, uriText); + if (res != 0) { + uriFreeUriMembersW(&uri); + return false; + } + + const unsigned int maskBefore = uriNormalizeSyntaxMaskRequiredW(&uri); + if (maskBefore != expectedMask) { + uriFreeUriMembersW(&uri); + return false; + } + + res = uriNormalizeSyntaxW(&uri); + if (res != 0) { + uriFreeUriMembersW(&uri); + return false; + } + + const unsigned int maskAfter = uriNormalizeSyntaxMaskRequiredW(&uri); + uriFreeUriMembersW(&uri); + + // Second call should be no problem + uriFreeUriMembersW(&uri); + + return (maskAfter == URI_NORMALIZED); + } +} // namespace + +TEST(UriSuite, TestNormalizeSyntaxMaskRequired) { + ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/", URI_NORMALIZED)); + ASSERT_TRUE(testNormalizeMaskHelper(L"httP://localhost/", URI_NORMALIZE_SCHEME)); + ASSERT_TRUE(testNormalizeMaskHelper(L"http://%0d@localhost/", URI_NORMALIZE_USER_INFO)); + ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhosT/", URI_NORMALIZE_HOST)); + ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/./abc", URI_NORMALIZE_PATH)); + ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/?AB%43", URI_NORMALIZE_QUERY)); + ASSERT_TRUE(testNormalizeMaskHelper(L"http://localhost/#AB%43", URI_NORMALIZE_FRAGMENT)); +} + +namespace { + bool testNormalizeSyntaxHelper(const wchar_t * uriText, const wchar_t * expectedNormalized, + unsigned int mask = static_cast<unsigned int>(-1)) { + UriParserStateW stateW; + int res; + + UriUriW testUri; + stateW.uri = &testUri; + res = uriParseUriW(&stateW, uriText); + if (res != 0) { + uriFreeUriMembersW(&testUri); + return false; + } + + // Expected result + UriUriW expectedUri; + stateW.uri = &expectedUri; + res = uriParseUriW(&stateW, expectedNormalized); + if (res != 0) { + uriFreeUriMembersW(&testUri); + uriFreeUriMembersW(&expectedUri); + return false; + } + + // First run + res = uriNormalizeSyntaxExW(&testUri, mask); + if (res != 0) { + uriFreeUriMembersW(&testUri); + uriFreeUriMembersW(&expectedUri); + return false; + } + + bool equalAfter = (URI_TRUE == uriEqualsUriW(&testUri, &expectedUri)); + + // Second run + res = uriNormalizeSyntaxExW(&testUri, mask); + if (res != 0) { + uriFreeUriMembersW(&testUri); + uriFreeUriMembersW(&expectedUri); + return false; + } + + equalAfter = equalAfter + && (URI_TRUE == uriEqualsUriW(&testUri, &expectedUri)); + + uriFreeUriMembersW(&testUri); + uriFreeUriMembersW(&expectedUri); + return equalAfter; + } +} // namespace + +TEST(UriSuite, TestNormalizeSyntax) { + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"eXAMPLE://a/./b/../b/%63/%7bfoo%7d", + L"example://a/b/c/%7Bfoo%7D")); + + // Testcase by Adrian Manrique + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"http://examp%4Ce.com/", + L"http://example.com/")); + + // Testcase by Adrian Manrique + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"http://example.com/a/b/%2E%2E/", + L"http://example.com/a/")); + + // Reported by Adrian Manrique + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"http://user:pass@SOMEHOST.COM:123", + L"http://user:pass@somehost.com:123")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"HTTP://a:b@HOST:123/./1/2/../%41?abc#def", + L"http://a:b@host:123/1/A?abc#def")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"../../abc", + L"../../abc")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"../../abc/..", + L"../../")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"../../abc/../def", + L"../../def")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"abc/..", + L"")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"abc/../", + L"")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"../../abc/./def", + L"../../abc/def")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"./def", + L"def")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"def/.", + L"def/")); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"./abc:def", + L"./abc:def")); +} + +TEST(UriSuite, TestNormalizeSyntaxComponents) { + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", + L"http://%41@EXAMPLE.ORG/../a?%41#%41", + URI_NORMALIZE_SCHEME)); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", + L"HTTP://A@EXAMPLE.ORG/../a?%41#%41", + URI_NORMALIZE_USER_INFO)); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", + L"HTTP://%41@example.org/../a?%41#%41", + URI_NORMALIZE_HOST)); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", + L"HTTP://%41@EXAMPLE.ORG/a?%41#%41", + URI_NORMALIZE_PATH)); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", + L"HTTP://%41@EXAMPLE.ORG/../a?A#%41", + URI_NORMALIZE_QUERY)); + + ASSERT_TRUE(testNormalizeSyntaxHelper( + L"HTTP://%41@EXAMPLE.ORG/../a?%41#%41", + L"HTTP://%41@EXAMPLE.ORG/../a?%41#A", + URI_NORMALIZE_FRAGMENT)); +} + TEST(UriSuite, TestNormalizeSyntaxPath) { // These are from GitHub issue #92 EXPECT_TRUE(testNormalizeSyntaxHelper( @@ -1532,690 +1532,690 @@ TEST(UriSuite, TestNormalizeSyntaxPath) { URI_NORMALIZE_PATH)); } -TEST(UriSuite, TestNormalizeCrashBug20080224) { - UriParserStateW stateW; - int res; - UriUriW testUri; - stateW.uri = &testUri; - - res = uriParseUriW(&stateW, L"http://example.org/abc//../def"); - ASSERT_TRUE(res == 0); - - // First call will make us owner of copied memory - res = uriNormalizeSyntaxExW(&testUri, URI_NORMALIZE_SCHEME); - ASSERT_TRUE(res == 0); - res = uriNormalizeSyntaxExW(&testUri, URI_NORMALIZE_HOST); - ASSERT_TRUE(res == 0); - - // Frees empty path segment -> crash - res = uriNormalizeSyntaxW(&testUri); - ASSERT_TRUE(res == 0); - - uriFreeUriMembersW(&testUri); -} - -namespace { - void testFilenameUriConversionHelper(const wchar_t * filename, - const wchar_t * uriString, bool forUnix, - const wchar_t * expectedUriString = NULL) { - const int prefixLen = forUnix ? 7 : 8; - if (! expectedUriString) { - expectedUriString = uriString; - } - - // Filename to URI string - const size_t uriBufferLen = prefixLen + 3 * wcslen(filename) + 1; - wchar_t * uriBuffer = new wchar_t[uriBufferLen]; - if (forUnix) { - uriUnixFilenameToUriStringW(filename, uriBuffer); - } else { - uriWindowsFilenameToUriStringW(filename, uriBuffer); - } -#ifdef HAVE_WPRINTF - // wprintf(L"1 [%s][%s]\n", uriBuffer, expectedUriString); -#endif - ASSERT_TRUE(!wcscmp(uriBuffer, expectedUriString)); - delete [] uriBuffer; - - // URI string to filename - const size_t filenameBufferLen = wcslen(uriString) + 1; - wchar_t * filenameBuffer = new wchar_t[filenameBufferLen]; - if (forUnix) { - uriUriStringToUnixFilenameW(uriString, filenameBuffer); - } else { - uriUriStringToWindowsFilenameW(uriString, filenameBuffer); - } -#ifdef HAVE_WPRINTF - // wprintf(L"2 [%s][%s]\n", filenameBuffer, filename); -#endif - ASSERT_TRUE(!wcscmp(filenameBuffer, filename)); - delete [] filenameBuffer; - } -} // namespace - -TEST(UriSuite, TestFilenameUriConversion) { - const bool FOR_UNIX = true; - const bool FOR_WINDOWS = false; - testFilenameUriConversionHelper(L"/bin/bash", L"file:///bin/bash", FOR_UNIX); - testFilenameUriConversionHelper(L"/bin/bash", L"file:/bin/bash", FOR_UNIX, L"file:///bin/bash"); - testFilenameUriConversionHelper(L"./configure", L"./configure", FOR_UNIX); - - testFilenameUriConversionHelper(L"E:\\Documents and Settings", L"file:///E:/Documents%20and%20Settings", FOR_WINDOWS); - testFilenameUriConversionHelper(L"c:\\path\\to\\file.txt", L"file:c:/path/to/file.txt", FOR_WINDOWS, L"file:///c:/path/to/file.txt"); - - testFilenameUriConversionHelper(L".\\Readme.txt", L"./Readme.txt", FOR_WINDOWS); - - testFilenameUriConversionHelper(L"index.htm", L"index.htm", FOR_WINDOWS); - testFilenameUriConversionHelper(L"index.htm", L"index.htm", FOR_UNIX); - - testFilenameUriConversionHelper(L"abc def", L"abc%20def", FOR_WINDOWS); - testFilenameUriConversionHelper(L"abc def", L"abc%20def", FOR_UNIX); - - testFilenameUriConversionHelper(L"\\\\Server01\\user\\docs\\Letter.txt", L"file://Server01/user/docs/Letter.txt", FOR_WINDOWS); -} - -TEST(UriSuite, TestCrashFreeUriMembersBug20080116) { - // Testcase by Adrian Manrique - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - uriParseUriA(&state, "http://test/?"); - uriNormalizeSyntaxA(&uri); - uriFreeUriMembersA(&uri); - - ASSERT_TRUE(true); -} - -namespace { - void helperTestQueryString(char const * uriString, int pairsExpected); -} - -TEST(UriSuite, TestCrashReport2418192) { - // Testcase by Harvey Vrsalovic - helperTestQueryString("http://svcs.cnn.com/weather/wrapper.jsp?&csiID=csi1", 1); -} - -TEST(UriSuite, TestPervertedQueryString) { - helperTestQueryString("http://example.org/?&&=&&&=&&&&==&===&====", 5); -} - -TEST(UriSuite, TestQueryStringEndingInEqualSignNonBug32) { - const char * queryString = "firstname=sdsd&lastname="; - - UriQueryListA * queryList = NULL; - int itemCount = 0; - const int res = uriDissectQueryMallocA(&queryList, &itemCount, - queryString, queryString + strlen(queryString)); - - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(itemCount == 2); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(strcmp(queryList->key, "firstname") == 0); - ASSERT_TRUE(strcmp(queryList->value, "sdsd") == 0); - ASSERT_TRUE(strcmp(queryList->next->key, "lastname") == 0); - ASSERT_TRUE(strcmp(queryList->next->value, "") == 0); - ASSERT_TRUE(queryList->next->next == NULL); - - uriFreeQueryListA(queryList); -} - -namespace { - void helperTestQueryString(char const * uriString, int pairsExpected) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - int res = uriParseUriA(&state, uriString); - ASSERT_TRUE(res == URI_SUCCESS); - - UriQueryListA * queryList = NULL; - int itemCount = 0; - - res = uriDissectQueryMallocA(&queryList, &itemCount, - uri.query.first, uri.query.afterLast); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(itemCount == pairsExpected); - uriFreeQueryListA(queryList); - uriFreeUriMembersA(&uri); - } -} // namespace - -TEST(UriSuite, TestCrashMakeOwnerBug20080207) { - // Testcase by Adrian Manrique - UriParserStateA state; - UriUriA sourceUri; - state.uri = &sourceUri; - const char * const sourceUriString = "http://user:pass@somehost.com:80/"; - if (uriParseUriA(&state, sourceUriString) != 0) { - ASSERT_TRUE(false); - } - if (uriNormalizeSyntaxA(&sourceUri) != 0) { - ASSERT_TRUE(false); - } - uriFreeUriMembersA(&sourceUri); - ASSERT_TRUE(true); -} - -namespace { - void testQueryListHelper(const wchar_t * input, int expectedItemCount) { - int res; - - UriBool spacePlusConversion = URI_TRUE; - UriBool normalizeBreaks = URI_FALSE; - UriBreakConversion breakConversion = URI_BR_DONT_TOUCH; - - int itemCount; - UriQueryListW * queryList; - res = uriDissectQueryMallocExW(&queryList, &itemCount, - input, input + wcslen(input), spacePlusConversion, breakConversion); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(itemCount == expectedItemCount); - ASSERT_TRUE((queryList == NULL) == (expectedItemCount == 0)); - - if (expectedItemCount != 0) { - // First - int charsRequired; - res = uriComposeQueryCharsRequiredExW(queryList, &charsRequired, spacePlusConversion, - normalizeBreaks); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(charsRequired >= (int)wcslen(input)); - - wchar_t * recomposed = new wchar_t[charsRequired + 1]; - int charsWritten; - res = uriComposeQueryExW(recomposed, queryList, charsRequired + 1, - &charsWritten, spacePlusConversion, normalizeBreaks); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(charsWritten <= charsRequired); - ASSERT_TRUE(charsWritten == (int)wcslen(input) + 1); - ASSERT_TRUE(!wcscmp(input, recomposed)); - delete [] recomposed; - - recomposed = NULL; - res = uriComposeQueryMallocW(&recomposed, queryList); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(recomposed != NULL); - ASSERT_TRUE(charsWritten == (int)wcslen(input) + 1); - ASSERT_TRUE(!wcscmp(input, recomposed)); - free(recomposed); - } - - uriFreeQueryListW(queryList); - } -} // namespace - -TEST(UriSuite, QueryList) { - testQueryListHelper(L"one=ONE&two=TWO", 2); - testQueryListHelper(L"one=ONE&two=&three=THREE", 3); - testQueryListHelper(L"one=ONE&two&three=THREE", 3); - testQueryListHelper(L"one=ONE", 1); - testQueryListHelper(L"one", 1); - testQueryListHelper(L"", 0); -} - -namespace { - void testQueryListPairHelper(const char * pair, const char * unescapedKey, - const char * unescapedValue, const char * fixed = NULL) { - int res; - UriQueryListA * queryList; - int itemCount; - - res = uriDissectQueryMallocA(&queryList, &itemCount, pair, pair + strlen(pair)); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(itemCount == 1); - ASSERT_TRUE(!strcmp(queryList->key, unescapedKey)); - ASSERT_TRUE(!strcmp(queryList->value, unescapedValue)); - - char * recomposed; - res = uriComposeQueryMallocA(&recomposed, queryList); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(recomposed != NULL); - ASSERT_TRUE(!strcmp(recomposed, (fixed != NULL) ? fixed : pair)); - free(recomposed); - uriFreeQueryListA(queryList); - } -} // namespace - -TEST(UriSuite, TestQueryListPair) { - testQueryListPairHelper("one+two+%26+three=%2B", "one two & three", "+"); - testQueryListPairHelper("one=two=three", "one", "two=three", "one=two%3Dthree"); - testQueryListPairHelper("one=two=three=four", "one", "two=three=four", "one=two%3Dthree%3Dfour"); -} - -TEST(UriSuite, TestQueryDissectionBug3590761) { - int res; - UriQueryListA * queryList; - int itemCount; - const char * const pair = "q=hello&x=&y="; - - res = uriDissectQueryMallocA(&queryList, &itemCount, pair, pair + strlen(pair)); - ASSERT_TRUE(res == URI_SUCCESS); - ASSERT_TRUE(queryList != NULL); - ASSERT_TRUE(itemCount == 3); - - ASSERT_TRUE(!strcmp(queryList->key, "q")); - ASSERT_TRUE(!strcmp(queryList->value, "hello")); - - ASSERT_TRUE(!strcmp(queryList->next->key, "x")); - ASSERT_TRUE(!strcmp(queryList->next->value, "")); - - ASSERT_TRUE(!strcmp(queryList->next->next->key, "y")); - ASSERT_TRUE(!strcmp(queryList->next->next->value, "")); - - ASSERT_TRUE(! queryList->next->next->next); - - uriFreeQueryListA(queryList); -} - -TEST(UriSuite, TestQueryCompositionMathCalc) { - UriQueryListA second = { /*.key =*/ "k2", /*.value =*/ "v2", /*.next =*/ NULL }; - UriQueryListA first = { /*.key =*/ "k1", /*.value =*/ "v1", /*.next =*/ &second }; - - int charsRequired; - ASSERT_TRUE(uriComposeQueryCharsRequiredA(&first, &charsRequired) - == URI_SUCCESS); - - const int FACTOR = 6; /* due to escaping with normalizeBreaks */ - ASSERT_TRUE((unsigned)charsRequired == - FACTOR * strlen(first.key) + 1 + FACTOR * strlen(first.value) - + 1 - + FACTOR * strlen(second.key) + 1 + FACTOR * strlen(second.value) - ); -} - -TEST(UriSuite, TestQueryCompositionMathWriteGoogleAutofuzz113244572) { - UriQueryListA second = { /*.key =*/ "\x11", /*.value =*/ NULL, /*.next =*/ NULL }; - UriQueryListA first = { /*.key =*/ "\x01", /*.value =*/ "\x02", /*.next =*/ &second }; - - const UriBool spaceToPlus = URI_TRUE; - const UriBool normalizeBreaks = URI_FALSE; /* for factor 3 but 6 */ - - const int charsRequired = (3 + 1 + 3) + 1 + (3); - - { - // Minimum space to hold everything fine - const char * const expected = "%01=%02" "&" "%11"; - char dest[charsRequired + 1]; - int charsWritten; - ASSERT_TRUE(uriComposeQueryExA(dest, &first, sizeof(dest), - &charsWritten, spaceToPlus, normalizeBreaks) - == URI_SUCCESS); - ASSERT_TRUE(! strcmp(dest, expected)); - ASSERT_TRUE(charsWritten == strlen(expected) + 1); - } - - { - // Previous math failed to take ampersand into account - char dest[charsRequired + 1 - 1]; - int charsWritten; - ASSERT_TRUE(uriComposeQueryExA(dest, &first, sizeof(dest), - &charsWritten, spaceToPlus, normalizeBreaks) - == URI_ERROR_OUTPUT_TOO_LARGE); - } -} - -TEST(UriSuite, TestFreeCrashBug20080827) { - char const * const sourceUri = "abc"; - char const * const baseUri = "http://www.example.org/"; - - int res; - UriParserStateA state; - UriUriA absoluteDest; - UriUriA relativeSource; - UriUriA absoluteBase; - - state.uri = &relativeSource; - res = uriParseUriA(&state, sourceUri); - ASSERT_TRUE(res == URI_SUCCESS); - - state.uri = &absoluteBase; - res = uriParseUriA(&state, baseUri); - ASSERT_TRUE(res == URI_SUCCESS); - - res = uriRemoveBaseUriA(&absoluteDest, &relativeSource, &absoluteBase, URI_FALSE); - ASSERT_TRUE(res == URI_ERROR_REMOVEBASE_REL_SOURCE); - - uriFreeUriMembersA(&relativeSource); - uriFreeUriMembersA(&absoluteBase); - uriFreeUriMembersA(&absoluteDest); // Crashed here -} - -TEST(UriSuite, TestInvalidInputBug16) { - UriParserStateA stateA; - UriUriA uriA; - stateA.uri = &uriA; - const char * const input = "A>B"; - - const int res = uriParseUriA(&stateA, input); - - ASSERT_TRUE(res == URI_ERROR_SYNTAX); - ASSERT_TRUE(stateA.errorPos == input + 1); - ASSERT_TRUE(stateA.errorCode == URI_ERROR_SYNTAX); /* failed previously */ - - uriFreeUriMembersA(&uriA); -} - -namespace { - void testEqualsHelper(const char * uri_to_test) { - UriParserStateA state; - UriUriA uriOne; - UriUriA uriTwo; - state.uri = &uriOne; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, uri_to_test)); - state.uri = &uriTwo; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, uri_to_test)); - ASSERT_TRUE(URI_TRUE == uriEqualsUriA(&uriOne, &uriTwo)); - uriFreeUriMembersA(&uriOne); - uriFreeUriMembersA(&uriTwo); - } -} // namespace - -TEST(UriSuite, TestEquals) { - testEqualsHelper("http://host"); - testEqualsHelper("http://host:123"); - testEqualsHelper("http://foo:bar@host:123"); - testEqualsHelper("http://foo:bar@host:123/"); - testEqualsHelper("http://foo:bar@host:123/path"); - testEqualsHelper("http://foo:bar@host:123/path?query"); - testEqualsHelper("http://foo:bar@host:123/path?query#fragment"); - - testEqualsHelper("path"); - testEqualsHelper("/path"); - testEqualsHelper("/path/"); - testEqualsHelper("//path/"); - testEqualsHelper("//host"); - testEqualsHelper("//host:123"); -} - -TEST(UriSuite, TestHostTextTerminationIssue15) { - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - - // Empty host and port - const char * const emptyHostWithPortUri = "//:123"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, emptyHostWithPortUri)); - ASSERT_TRUE(uri.hostText.first == emptyHostWithPortUri + strlen("//")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - ASSERT_TRUE(uri.portText.first == emptyHostWithPortUri - + strlen("//:")); - ASSERT_TRUE(uri.portText.afterLast == uri.portText.first - + strlen("123")); - uriFreeUriMembersA(&uri); - - // Non-empty host and port - const char * const hostWithPortUri = "//h:123"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, hostWithPortUri)); - ASSERT_TRUE(uri.hostText.first == hostWithPortUri + strlen("//")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first - + strlen("h")); - ASSERT_TRUE(uri.portText.first == hostWithPortUri + strlen("//h:")); - ASSERT_TRUE(uri.portText.afterLast == uri.portText.first - + strlen("123")); - uriFreeUriMembersA(&uri); - - // Empty host, empty user info - const char * const emptyHostEmptyUserInfoUri = "//@"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, - emptyHostEmptyUserInfoUri)); - ASSERT_TRUE(uri.userInfo.first == emptyHostEmptyUserInfoUri - + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 0); - ASSERT_TRUE(uri.hostText.first == emptyHostEmptyUserInfoUri - + strlen("//@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - uriFreeUriMembersA(&uri); - - // Non-empty host, empty user info - const char * const hostEmptyUserInfoUri = "//@h"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, hostEmptyUserInfoUri)); - ASSERT_TRUE(uri.userInfo.first == hostEmptyUserInfoUri + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 0); - ASSERT_TRUE(uri.hostText.first == hostEmptyUserInfoUri - + strlen("//@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first - + strlen("h")); - uriFreeUriMembersA(&uri); - - // Empty host, non-empty user info - const char * const emptyHostWithUserInfoUri = "//:@"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, - emptyHostWithUserInfoUri)); - ASSERT_TRUE(uri.userInfo.first == emptyHostWithUserInfoUri - + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 1); - ASSERT_TRUE(uri.hostText.first == emptyHostWithUserInfoUri - + strlen("//:@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - uriFreeUriMembersA(&uri); - - // Exact case from issue #15 - const char * const issue15Uri = "//:%aa@"; - ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, issue15Uri)); - ASSERT_TRUE(uri.userInfo.first == issue15Uri + strlen("//")); - ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first - + strlen(":%aa")); - ASSERT_TRUE(uri.hostText.first == issue15Uri + strlen("//:%aa@")); - ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); - uriFreeUriMembersA(&uri); -} - -namespace { - void testCompareRangeHelper(const char * a, const char * b, int expected, bool avoidNullRange = true) { - UriTextRangeA ra; - UriTextRangeA rb; - - if (a) { - ra.first = a; - ra.afterLast = a + strlen(a); - } else { - ra.first = NULL; - ra.afterLast = NULL; - } - - if (b) { - rb.first = b; - rb.afterLast = b + strlen(b); - } else { - rb.first = NULL; - rb.afterLast = NULL; - } - - const int received = uriCompareRangeA( - ((a == NULL) && avoidNullRange) ? NULL : &ra, - ((b == NULL) && avoidNullRange) ? NULL : &rb); - if (received != expected) { - printf("Comparing <%s> to <%s> yields %d, expected %d.\n", - a, b, received, expected); - } - ASSERT_TRUE(received == expected); - } -} // namespace - -TEST(UriSuite, TestRangeComparison) { - testCompareRangeHelper("", "", 0); - testCompareRangeHelper("a", "", 1); - testCompareRangeHelper("", "a", -1); - - testCompareRangeHelper("a", "a", 0); - testCompareRangeHelper("a", "b", -1); - testCompareRangeHelper("b", "a", 1); - - testCompareRangeHelper("a", "aa", -1); - testCompareRangeHelper("aa", "a", 1); - - // Fixed with 0.8.1: - testCompareRangeHelper(NULL, "a", -1); - testCompareRangeHelper("a", NULL, 1); - testCompareRangeHelper(NULL, NULL, 0); - - // Fixed with 0.8.3 - const bool KEEP_NULL_RANGE = false; - const bool AVOID_NULL_RANGE = true; - testCompareRangeHelper(NULL, "", -1, AVOID_NULL_RANGE); - testCompareRangeHelper(NULL, "", -1, KEEP_NULL_RANGE); - testCompareRangeHelper("", NULL, 1, AVOID_NULL_RANGE); - testCompareRangeHelper("", NULL, 1, KEEP_NULL_RANGE); -} - -namespace { - void testRemoveBaseUriHelper(const char * expected, - const char * absSourceStr, - const char * absBaseStr) { - UriParserStateA state; - UriUriA absSource; - UriUriA absBase; - UriUriA dest; - - state.uri = &absSource; - ASSERT_TRUE(uriParseUriA(&state, absSourceStr) == URI_SUCCESS); - - state.uri = &absBase; - ASSERT_TRUE(uriParseUriA(&state, absBaseStr) == URI_SUCCESS); - - ASSERT_TRUE(uriRemoveBaseUriA(&dest, &absSource, &absBase, URI_FALSE) - == URI_SUCCESS); - - int size = 0; - ASSERT_TRUE(uriToStringCharsRequiredA(&dest, &size) == URI_SUCCESS); - char * const buffer = (char *)malloc(size + 1); - ASSERT_TRUE(buffer); - ASSERT_TRUE(uriToStringA(buffer, &dest, size + 1, &size) - == URI_SUCCESS); - if (strcmp(buffer, expected)) { - printf("Expected \"%s\" but got \"%s\"\n", expected, buffer); - ASSERT_TRUE(0); - } - free(buffer); - - uriFreeUriMembersA(&absSource); - uriFreeUriMembersA(&absBase); - uriFreeUriMembersA(&dest); - } -} // namespace - -TEST(UriSuite, TestRangeComparisonRemoveBaseUriIssue19) { - // scheme - testRemoveBaseUriHelper("scheme://host/source", - "scheme://host/source", - "schemelonger://host/base"); - testRemoveBaseUriHelper("schemelonger://host/source", - "schemelonger://host/source", - "scheme://host/base"); - - // hostText - testRemoveBaseUriHelper("//host/source", - "http://host/source", - "http://hostlonger/base"); - testRemoveBaseUriHelper("//hostlonger/source", - "http://hostlonger/source", - "http://host/base"); - - // hostData.ipFuture - testRemoveBaseUriHelper("//[v7.host]/source", - "http://[v7.host]/source", - "http://[v7.hostlonger]/base"); - testRemoveBaseUriHelper("//[v7.hostlonger]/source", - "http://[v7.hostlonger]/source", - "http://host/base"); - - // path - testRemoveBaseUriHelper("path1", - "http://host/path1", - "http://host/path111"); - testRemoveBaseUriHelper("../path1/path2", - "http://host/path1/path2", - "http://host/path111/path222"); - testRemoveBaseUriHelper("path111", - "http://host/path111", - "http://host/path1"); - testRemoveBaseUriHelper("../path111/path222", - "http://host/path111/path222", - "http://host/path1/path2"); - - // Exact issue #19 - testRemoveBaseUriHelper("//example/x/abc", - "http://example/x/abc", - "http://example2/x/y/z"); -} - -TEST(ErrorPosSuite, TestErrorPosIPvFuture) { - UriUriA uri; - const char * errorPos; - - const char * const uriText = "http://[vA.123456"; // missing "]" - EXPECT_EQ(uriParseSingleUriA(&uri, uriText, &errorPos), - URI_ERROR_SYNTAX); - EXPECT_EQ(errorPos, uriText + strlen(uriText)); -} - -TEST(UriParseSingleSuite, Success) { - UriUriA uri; - - EXPECT_EQ(uriParseSingleUriA(&uri, "file:///home/user/song.mp3", NULL), - URI_SUCCESS); - - uriFreeUriMembersA(&uri); -} - -TEST(UriParseSingleSuite, ErrorSyntaxParseErrorSetsErrorPos) { - UriUriA uri; - const char * errorPos; - const char * const uriString = "abc{}def"; - - EXPECT_EQ(uriParseSingleUriA(&uri, uriString, &errorPos), - URI_ERROR_SYNTAX); - EXPECT_EQ(errorPos, uriString + strlen("abc")); - - uriFreeUriMembersA(&uri); -} - -TEST(UriParseSingleSuite, ErrorNullFirstDetected) { - UriUriA uri; - const char * errorPos; - - EXPECT_EQ(uriParseSingleUriExA(&uri, NULL, "notnull", &errorPos), - URI_ERROR_NULL); -} - -TEST(UriParseSingleSuite, ErrorNullAfterLastDetected) { - UriUriA uri; - - EXPECT_EQ(uriParseSingleUriExA(&uri, "foo", NULL, NULL), URI_SUCCESS); - - uriFreeUriMembersA(&uri); -} - -TEST(UriParseSingleSuite, ErrorNullMemoryManagerDetected) { - UriUriA uri; - const char * errorPos; - const char * const uriString = "somethingwellformed"; - - EXPECT_EQ(uriParseSingleUriExMmA(&uri, - uriString, - uriString + strlen(uriString), - &errorPos, NULL), URI_SUCCESS); - - EXPECT_EQ(uriFreeUriMembersMmA(&uri, NULL), URI_SUCCESS); -} - -TEST(FreeUriMembersSuite, MultiFreeWorksFine) { - UriUriA uri; - - EXPECT_EQ(uriParseSingleUriA(&uri, "file:///home/user/song.mp3", NULL), - URI_SUCCESS); - - UriUriA uriBackup = uri; - EXPECT_EQ(memcmp(&uriBackup, &uri, sizeof(UriUriA)), 0); - - uriFreeUriMembersA(&uri); - - // Did some pointers change (to NULL)? - EXPECT_NE(memcmp(&uriBackup, &uri, sizeof(UriUriA)), 0); - - uriFreeUriMembersA(&uri); // second time -} - +TEST(UriSuite, TestNormalizeCrashBug20080224) { + UriParserStateW stateW; + int res; + UriUriW testUri; + stateW.uri = &testUri; + + res = uriParseUriW(&stateW, L"http://example.org/abc//../def"); + ASSERT_TRUE(res == 0); + + // First call will make us owner of copied memory + res = uriNormalizeSyntaxExW(&testUri, URI_NORMALIZE_SCHEME); + ASSERT_TRUE(res == 0); + res = uriNormalizeSyntaxExW(&testUri, URI_NORMALIZE_HOST); + ASSERT_TRUE(res == 0); + + // Frees empty path segment -> crash + res = uriNormalizeSyntaxW(&testUri); + ASSERT_TRUE(res == 0); + + uriFreeUriMembersW(&testUri); +} + +namespace { + void testFilenameUriConversionHelper(const wchar_t * filename, + const wchar_t * uriString, bool forUnix, + const wchar_t * expectedUriString = NULL) { + const int prefixLen = forUnix ? 7 : 8; + if (! expectedUriString) { + expectedUriString = uriString; + } + + // Filename to URI string + const size_t uriBufferLen = prefixLen + 3 * wcslen(filename) + 1; + wchar_t * uriBuffer = new wchar_t[uriBufferLen]; + if (forUnix) { + uriUnixFilenameToUriStringW(filename, uriBuffer); + } else { + uriWindowsFilenameToUriStringW(filename, uriBuffer); + } +#ifdef HAVE_WPRINTF + // wprintf(L"1 [%s][%s]\n", uriBuffer, expectedUriString); +#endif + ASSERT_TRUE(!wcscmp(uriBuffer, expectedUriString)); + delete [] uriBuffer; + + // URI string to filename + const size_t filenameBufferLen = wcslen(uriString) + 1; + wchar_t * filenameBuffer = new wchar_t[filenameBufferLen]; + if (forUnix) { + uriUriStringToUnixFilenameW(uriString, filenameBuffer); + } else { + uriUriStringToWindowsFilenameW(uriString, filenameBuffer); + } +#ifdef HAVE_WPRINTF + // wprintf(L"2 [%s][%s]\n", filenameBuffer, filename); +#endif + ASSERT_TRUE(!wcscmp(filenameBuffer, filename)); + delete [] filenameBuffer; + } +} // namespace + +TEST(UriSuite, TestFilenameUriConversion) { + const bool FOR_UNIX = true; + const bool FOR_WINDOWS = false; + testFilenameUriConversionHelper(L"/bin/bash", L"file:///bin/bash", FOR_UNIX); + testFilenameUriConversionHelper(L"/bin/bash", L"file:/bin/bash", FOR_UNIX, L"file:///bin/bash"); + testFilenameUriConversionHelper(L"./configure", L"./configure", FOR_UNIX); + + testFilenameUriConversionHelper(L"E:\\Documents and Settings", L"file:///E:/Documents%20and%20Settings", FOR_WINDOWS); + testFilenameUriConversionHelper(L"c:\\path\\to\\file.txt", L"file:c:/path/to/file.txt", FOR_WINDOWS, L"file:///c:/path/to/file.txt"); + + testFilenameUriConversionHelper(L".\\Readme.txt", L"./Readme.txt", FOR_WINDOWS); + + testFilenameUriConversionHelper(L"index.htm", L"index.htm", FOR_WINDOWS); + testFilenameUriConversionHelper(L"index.htm", L"index.htm", FOR_UNIX); + + testFilenameUriConversionHelper(L"abc def", L"abc%20def", FOR_WINDOWS); + testFilenameUriConversionHelper(L"abc def", L"abc%20def", FOR_UNIX); + + testFilenameUriConversionHelper(L"\\\\Server01\\user\\docs\\Letter.txt", L"file://Server01/user/docs/Letter.txt", FOR_WINDOWS); +} + +TEST(UriSuite, TestCrashFreeUriMembersBug20080116) { + // Testcase by Adrian Manrique + UriParserStateA state; + UriUriA uri; + state.uri = &uri; + uriParseUriA(&state, "http://test/?"); + uriNormalizeSyntaxA(&uri); + uriFreeUriMembersA(&uri); + + ASSERT_TRUE(true); +} + +namespace { + void helperTestQueryString(char const * uriString, int pairsExpected); +} + +TEST(UriSuite, TestCrashReport2418192) { + // Testcase by Harvey Vrsalovic + helperTestQueryString("http://svcs.cnn.com/weather/wrapper.jsp?&csiID=csi1", 1); +} + +TEST(UriSuite, TestPervertedQueryString) { + helperTestQueryString("http://example.org/?&&=&&&=&&&&==&===&====", 5); +} + +TEST(UriSuite, TestQueryStringEndingInEqualSignNonBug32) { + const char * queryString = "firstname=sdsd&lastname="; + + UriQueryListA * queryList = NULL; + int itemCount = 0; + const int res = uriDissectQueryMallocA(&queryList, &itemCount, + queryString, queryString + strlen(queryString)); + + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(itemCount == 2); + ASSERT_TRUE(queryList != NULL); + ASSERT_TRUE(strcmp(queryList->key, "firstname") == 0); + ASSERT_TRUE(strcmp(queryList->value, "sdsd") == 0); + ASSERT_TRUE(strcmp(queryList->next->key, "lastname") == 0); + ASSERT_TRUE(strcmp(queryList->next->value, "") == 0); + ASSERT_TRUE(queryList->next->next == NULL); + + uriFreeQueryListA(queryList); +} + +namespace { + void helperTestQueryString(char const * uriString, int pairsExpected) { + UriParserStateA state; + UriUriA uri; + state.uri = &uri; + int res = uriParseUriA(&state, uriString); + ASSERT_TRUE(res == URI_SUCCESS); + + UriQueryListA * queryList = NULL; + int itemCount = 0; + + res = uriDissectQueryMallocA(&queryList, &itemCount, + uri.query.first, uri.query.afterLast); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(queryList != NULL); + ASSERT_TRUE(itemCount == pairsExpected); + uriFreeQueryListA(queryList); + uriFreeUriMembersA(&uri); + } +} // namespace + +TEST(UriSuite, TestCrashMakeOwnerBug20080207) { + // Testcase by Adrian Manrique + UriParserStateA state; + UriUriA sourceUri; + state.uri = &sourceUri; + const char * const sourceUriString = "http://user:pass@somehost.com:80/"; + if (uriParseUriA(&state, sourceUriString) != 0) { + ASSERT_TRUE(false); + } + if (uriNormalizeSyntaxA(&sourceUri) != 0) { + ASSERT_TRUE(false); + } + uriFreeUriMembersA(&sourceUri); + ASSERT_TRUE(true); +} + +namespace { + void testQueryListHelper(const wchar_t * input, int expectedItemCount) { + int res; + + UriBool spacePlusConversion = URI_TRUE; + UriBool normalizeBreaks = URI_FALSE; + UriBreakConversion breakConversion = URI_BR_DONT_TOUCH; + + int itemCount; + UriQueryListW * queryList; + res = uriDissectQueryMallocExW(&queryList, &itemCount, + input, input + wcslen(input), spacePlusConversion, breakConversion); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(itemCount == expectedItemCount); + ASSERT_TRUE((queryList == NULL) == (expectedItemCount == 0)); + + if (expectedItemCount != 0) { + // First + int charsRequired; + res = uriComposeQueryCharsRequiredExW(queryList, &charsRequired, spacePlusConversion, + normalizeBreaks); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(charsRequired >= (int)wcslen(input)); + + wchar_t * recomposed = new wchar_t[charsRequired + 1]; + int charsWritten; + res = uriComposeQueryExW(recomposed, queryList, charsRequired + 1, + &charsWritten, spacePlusConversion, normalizeBreaks); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(charsWritten <= charsRequired); + ASSERT_TRUE(charsWritten == (int)wcslen(input) + 1); + ASSERT_TRUE(!wcscmp(input, recomposed)); + delete [] recomposed; + + recomposed = NULL; + res = uriComposeQueryMallocW(&recomposed, queryList); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(recomposed != NULL); + ASSERT_TRUE(charsWritten == (int)wcslen(input) + 1); + ASSERT_TRUE(!wcscmp(input, recomposed)); + free(recomposed); + } + + uriFreeQueryListW(queryList); + } +} // namespace + +TEST(UriSuite, QueryList) { + testQueryListHelper(L"one=ONE&two=TWO", 2); + testQueryListHelper(L"one=ONE&two=&three=THREE", 3); + testQueryListHelper(L"one=ONE&two&three=THREE", 3); + testQueryListHelper(L"one=ONE", 1); + testQueryListHelper(L"one", 1); + testQueryListHelper(L"", 0); +} + +namespace { + void testQueryListPairHelper(const char * pair, const char * unescapedKey, + const char * unescapedValue, const char * fixed = NULL) { + int res; + UriQueryListA * queryList; + int itemCount; + + res = uriDissectQueryMallocA(&queryList, &itemCount, pair, pair + strlen(pair)); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(queryList != NULL); + ASSERT_TRUE(itemCount == 1); + ASSERT_TRUE(!strcmp(queryList->key, unescapedKey)); + ASSERT_TRUE(!strcmp(queryList->value, unescapedValue)); + + char * recomposed; + res = uriComposeQueryMallocA(&recomposed, queryList); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(recomposed != NULL); + ASSERT_TRUE(!strcmp(recomposed, (fixed != NULL) ? fixed : pair)); + free(recomposed); + uriFreeQueryListA(queryList); + } +} // namespace + +TEST(UriSuite, TestQueryListPair) { + testQueryListPairHelper("one+two+%26+three=%2B", "one two & three", "+"); + testQueryListPairHelper("one=two=three", "one", "two=three", "one=two%3Dthree"); + testQueryListPairHelper("one=two=three=four", "one", "two=three=four", "one=two%3Dthree%3Dfour"); +} + +TEST(UriSuite, TestQueryDissectionBug3590761) { + int res; + UriQueryListA * queryList; + int itemCount; + const char * const pair = "q=hello&x=&y="; + + res = uriDissectQueryMallocA(&queryList, &itemCount, pair, pair + strlen(pair)); + ASSERT_TRUE(res == URI_SUCCESS); + ASSERT_TRUE(queryList != NULL); + ASSERT_TRUE(itemCount == 3); + + ASSERT_TRUE(!strcmp(queryList->key, "q")); + ASSERT_TRUE(!strcmp(queryList->value, "hello")); + + ASSERT_TRUE(!strcmp(queryList->next->key, "x")); + ASSERT_TRUE(!strcmp(queryList->next->value, "")); + + ASSERT_TRUE(!strcmp(queryList->next->next->key, "y")); + ASSERT_TRUE(!strcmp(queryList->next->next->value, "")); + + ASSERT_TRUE(! queryList->next->next->next); + + uriFreeQueryListA(queryList); +} + +TEST(UriSuite, TestQueryCompositionMathCalc) { + UriQueryListA second = { /*.key =*/ "k2", /*.value =*/ "v2", /*.next =*/ NULL }; + UriQueryListA first = { /*.key =*/ "k1", /*.value =*/ "v1", /*.next =*/ &second }; + + int charsRequired; + ASSERT_TRUE(uriComposeQueryCharsRequiredA(&first, &charsRequired) + == URI_SUCCESS); + + const int FACTOR = 6; /* due to escaping with normalizeBreaks */ + ASSERT_TRUE((unsigned)charsRequired == + FACTOR * strlen(first.key) + 1 + FACTOR * strlen(first.value) + + 1 + + FACTOR * strlen(second.key) + 1 + FACTOR * strlen(second.value) + ); +} + +TEST(UriSuite, TestQueryCompositionMathWriteGoogleAutofuzz113244572) { + UriQueryListA second = { /*.key =*/ "\x11", /*.value =*/ NULL, /*.next =*/ NULL }; + UriQueryListA first = { /*.key =*/ "\x01", /*.value =*/ "\x02", /*.next =*/ &second }; + + const UriBool spaceToPlus = URI_TRUE; + const UriBool normalizeBreaks = URI_FALSE; /* for factor 3 but 6 */ + + const int charsRequired = (3 + 1 + 3) + 1 + (3); + + { + // Minimum space to hold everything fine + const char * const expected = "%01=%02" "&" "%11"; + char dest[charsRequired + 1]; + int charsWritten; + ASSERT_TRUE(uriComposeQueryExA(dest, &first, sizeof(dest), + &charsWritten, spaceToPlus, normalizeBreaks) + == URI_SUCCESS); + ASSERT_TRUE(! strcmp(dest, expected)); + ASSERT_TRUE(charsWritten == strlen(expected) + 1); + } + + { + // Previous math failed to take ampersand into account + char dest[charsRequired + 1 - 1]; + int charsWritten; + ASSERT_TRUE(uriComposeQueryExA(dest, &first, sizeof(dest), + &charsWritten, spaceToPlus, normalizeBreaks) + == URI_ERROR_OUTPUT_TOO_LARGE); + } +} + +TEST(UriSuite, TestFreeCrashBug20080827) { + char const * const sourceUri = "abc"; + char const * const baseUri = "http://www.example.org/"; + + int res; + UriParserStateA state; + UriUriA absoluteDest; + UriUriA relativeSource; + UriUriA absoluteBase; + + state.uri = &relativeSource; + res = uriParseUriA(&state, sourceUri); + ASSERT_TRUE(res == URI_SUCCESS); + + state.uri = &absoluteBase; + res = uriParseUriA(&state, baseUri); + ASSERT_TRUE(res == URI_SUCCESS); + + res = uriRemoveBaseUriA(&absoluteDest, &relativeSource, &absoluteBase, URI_FALSE); + ASSERT_TRUE(res == URI_ERROR_REMOVEBASE_REL_SOURCE); + + uriFreeUriMembersA(&relativeSource); + uriFreeUriMembersA(&absoluteBase); + uriFreeUriMembersA(&absoluteDest); // Crashed here +} + +TEST(UriSuite, TestInvalidInputBug16) { + UriParserStateA stateA; + UriUriA uriA; + stateA.uri = &uriA; + const char * const input = "A>B"; + + const int res = uriParseUriA(&stateA, input); + + ASSERT_TRUE(res == URI_ERROR_SYNTAX); + ASSERT_TRUE(stateA.errorPos == input + 1); + ASSERT_TRUE(stateA.errorCode == URI_ERROR_SYNTAX); /* failed previously */ + + uriFreeUriMembersA(&uriA); +} + +namespace { + void testEqualsHelper(const char * uri_to_test) { + UriParserStateA state; + UriUriA uriOne; + UriUriA uriTwo; + state.uri = &uriOne; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, uri_to_test)); + state.uri = &uriTwo; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, uri_to_test)); + ASSERT_TRUE(URI_TRUE == uriEqualsUriA(&uriOne, &uriTwo)); + uriFreeUriMembersA(&uriOne); + uriFreeUriMembersA(&uriTwo); + } +} // namespace + +TEST(UriSuite, TestEquals) { + testEqualsHelper("http://host"); + testEqualsHelper("http://host:123"); + testEqualsHelper("http://foo:bar@host:123"); + testEqualsHelper("http://foo:bar@host:123/"); + testEqualsHelper("http://foo:bar@host:123/path"); + testEqualsHelper("http://foo:bar@host:123/path?query"); + testEqualsHelper("http://foo:bar@host:123/path?query#fragment"); + + testEqualsHelper("path"); + testEqualsHelper("/path"); + testEqualsHelper("/path/"); + testEqualsHelper("//path/"); + testEqualsHelper("//host"); + testEqualsHelper("//host:123"); +} + +TEST(UriSuite, TestHostTextTerminationIssue15) { + UriParserStateA state; + UriUriA uri; + state.uri = &uri; + + // Empty host and port + const char * const emptyHostWithPortUri = "//:123"; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, emptyHostWithPortUri)); + ASSERT_TRUE(uri.hostText.first == emptyHostWithPortUri + strlen("//")); + ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); + ASSERT_TRUE(uri.portText.first == emptyHostWithPortUri + + strlen("//:")); + ASSERT_TRUE(uri.portText.afterLast == uri.portText.first + + strlen("123")); + uriFreeUriMembersA(&uri); + + // Non-empty host and port + const char * const hostWithPortUri = "//h:123"; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, hostWithPortUri)); + ASSERT_TRUE(uri.hostText.first == hostWithPortUri + strlen("//")); + ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + + strlen("h")); + ASSERT_TRUE(uri.portText.first == hostWithPortUri + strlen("//h:")); + ASSERT_TRUE(uri.portText.afterLast == uri.portText.first + + strlen("123")); + uriFreeUriMembersA(&uri); + + // Empty host, empty user info + const char * const emptyHostEmptyUserInfoUri = "//@"; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, + emptyHostEmptyUserInfoUri)); + ASSERT_TRUE(uri.userInfo.first == emptyHostEmptyUserInfoUri + + strlen("//")); + ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 0); + ASSERT_TRUE(uri.hostText.first == emptyHostEmptyUserInfoUri + + strlen("//@")); + ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); + uriFreeUriMembersA(&uri); + + // Non-empty host, empty user info + const char * const hostEmptyUserInfoUri = "//@h"; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, hostEmptyUserInfoUri)); + ASSERT_TRUE(uri.userInfo.first == hostEmptyUserInfoUri + strlen("//")); + ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 0); + ASSERT_TRUE(uri.hostText.first == hostEmptyUserInfoUri + + strlen("//@")); + ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + + strlen("h")); + uriFreeUriMembersA(&uri); + + // Empty host, non-empty user info + const char * const emptyHostWithUserInfoUri = "//:@"; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, + emptyHostWithUserInfoUri)); + ASSERT_TRUE(uri.userInfo.first == emptyHostWithUserInfoUri + + strlen("//")); + ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + 1); + ASSERT_TRUE(uri.hostText.first == emptyHostWithUserInfoUri + + strlen("//:@")); + ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); + uriFreeUriMembersA(&uri); + + // Exact case from issue #15 + const char * const issue15Uri = "//:%aa@"; + ASSERT_TRUE(URI_SUCCESS == uriParseUriA(&state, issue15Uri)); + ASSERT_TRUE(uri.userInfo.first == issue15Uri + strlen("//")); + ASSERT_TRUE(uri.userInfo.afterLast == uri.userInfo.first + + strlen(":%aa")); + ASSERT_TRUE(uri.hostText.first == issue15Uri + strlen("//:%aa@")); + ASSERT_TRUE(uri.hostText.afterLast == uri.hostText.first + 0); + uriFreeUriMembersA(&uri); +} + +namespace { + void testCompareRangeHelper(const char * a, const char * b, int expected, bool avoidNullRange = true) { + UriTextRangeA ra; + UriTextRangeA rb; + + if (a) { + ra.first = a; + ra.afterLast = a + strlen(a); + } else { + ra.first = NULL; + ra.afterLast = NULL; + } + + if (b) { + rb.first = b; + rb.afterLast = b + strlen(b); + } else { + rb.first = NULL; + rb.afterLast = NULL; + } + + const int received = uriCompareRangeA( + ((a == NULL) && avoidNullRange) ? NULL : &ra, + ((b == NULL) && avoidNullRange) ? NULL : &rb); + if (received != expected) { + printf("Comparing <%s> to <%s> yields %d, expected %d.\n", + a, b, received, expected); + } + ASSERT_TRUE(received == expected); + } +} // namespace + +TEST(UriSuite, TestRangeComparison) { + testCompareRangeHelper("", "", 0); + testCompareRangeHelper("a", "", 1); + testCompareRangeHelper("", "a", -1); + + testCompareRangeHelper("a", "a", 0); + testCompareRangeHelper("a", "b", -1); + testCompareRangeHelper("b", "a", 1); + + testCompareRangeHelper("a", "aa", -1); + testCompareRangeHelper("aa", "a", 1); + + // Fixed with 0.8.1: + testCompareRangeHelper(NULL, "a", -1); + testCompareRangeHelper("a", NULL, 1); + testCompareRangeHelper(NULL, NULL, 0); + + // Fixed with 0.8.3 + const bool KEEP_NULL_RANGE = false; + const bool AVOID_NULL_RANGE = true; + testCompareRangeHelper(NULL, "", -1, AVOID_NULL_RANGE); + testCompareRangeHelper(NULL, "", -1, KEEP_NULL_RANGE); + testCompareRangeHelper("", NULL, 1, AVOID_NULL_RANGE); + testCompareRangeHelper("", NULL, 1, KEEP_NULL_RANGE); +} + +namespace { + void testRemoveBaseUriHelper(const char * expected, + const char * absSourceStr, + const char * absBaseStr) { + UriParserStateA state; + UriUriA absSource; + UriUriA absBase; + UriUriA dest; + + state.uri = &absSource; + ASSERT_TRUE(uriParseUriA(&state, absSourceStr) == URI_SUCCESS); + + state.uri = &absBase; + ASSERT_TRUE(uriParseUriA(&state, absBaseStr) == URI_SUCCESS); + + ASSERT_TRUE(uriRemoveBaseUriA(&dest, &absSource, &absBase, URI_FALSE) + == URI_SUCCESS); + + int size = 0; + ASSERT_TRUE(uriToStringCharsRequiredA(&dest, &size) == URI_SUCCESS); + char * const buffer = (char *)malloc(size + 1); + ASSERT_TRUE(buffer); + ASSERT_TRUE(uriToStringA(buffer, &dest, size + 1, &size) + == URI_SUCCESS); + if (strcmp(buffer, expected)) { + printf("Expected \"%s\" but got \"%s\"\n", expected, buffer); + ASSERT_TRUE(0); + } + free(buffer); + + uriFreeUriMembersA(&absSource); + uriFreeUriMembersA(&absBase); + uriFreeUriMembersA(&dest); + } +} // namespace + +TEST(UriSuite, TestRangeComparisonRemoveBaseUriIssue19) { + // scheme + testRemoveBaseUriHelper("scheme://host/source", + "scheme://host/source", + "schemelonger://host/base"); + testRemoveBaseUriHelper("schemelonger://host/source", + "schemelonger://host/source", + "scheme://host/base"); + + // hostText + testRemoveBaseUriHelper("//host/source", + "http://host/source", + "http://hostlonger/base"); + testRemoveBaseUriHelper("//hostlonger/source", + "http://hostlonger/source", + "http://host/base"); + + // hostData.ipFuture + testRemoveBaseUriHelper("//[v7.host]/source", + "http://[v7.host]/source", + "http://[v7.hostlonger]/base"); + testRemoveBaseUriHelper("//[v7.hostlonger]/source", + "http://[v7.hostlonger]/source", + "http://host/base"); + + // path + testRemoveBaseUriHelper("path1", + "http://host/path1", + "http://host/path111"); + testRemoveBaseUriHelper("../path1/path2", + "http://host/path1/path2", + "http://host/path111/path222"); + testRemoveBaseUriHelper("path111", + "http://host/path111", + "http://host/path1"); + testRemoveBaseUriHelper("../path111/path222", + "http://host/path111/path222", + "http://host/path1/path2"); + + // Exact issue #19 + testRemoveBaseUriHelper("//example/x/abc", + "http://example/x/abc", + "http://example2/x/y/z"); +} + +TEST(ErrorPosSuite, TestErrorPosIPvFuture) { + UriUriA uri; + const char * errorPos; + + const char * const uriText = "http://[vA.123456"; // missing "]" + EXPECT_EQ(uriParseSingleUriA(&uri, uriText, &errorPos), + URI_ERROR_SYNTAX); + EXPECT_EQ(errorPos, uriText + strlen(uriText)); +} + +TEST(UriParseSingleSuite, Success) { + UriUriA uri; + + EXPECT_EQ(uriParseSingleUriA(&uri, "file:///home/user/song.mp3", NULL), + URI_SUCCESS); + + uriFreeUriMembersA(&uri); +} + +TEST(UriParseSingleSuite, ErrorSyntaxParseErrorSetsErrorPos) { + UriUriA uri; + const char * errorPos; + const char * const uriString = "abc{}def"; + + EXPECT_EQ(uriParseSingleUriA(&uri, uriString, &errorPos), + URI_ERROR_SYNTAX); + EXPECT_EQ(errorPos, uriString + strlen("abc")); + + uriFreeUriMembersA(&uri); +} + +TEST(UriParseSingleSuite, ErrorNullFirstDetected) { + UriUriA uri; + const char * errorPos; + + EXPECT_EQ(uriParseSingleUriExA(&uri, NULL, "notnull", &errorPos), + URI_ERROR_NULL); +} + +TEST(UriParseSingleSuite, ErrorNullAfterLastDetected) { + UriUriA uri; + + EXPECT_EQ(uriParseSingleUriExA(&uri, "foo", NULL, NULL), URI_SUCCESS); + + uriFreeUriMembersA(&uri); +} + +TEST(UriParseSingleSuite, ErrorNullMemoryManagerDetected) { + UriUriA uri; + const char * errorPos; + const char * const uriString = "somethingwellformed"; + + EXPECT_EQ(uriParseSingleUriExMmA(&uri, + uriString, + uriString + strlen(uriString), + &errorPos, NULL), URI_SUCCESS); + + EXPECT_EQ(uriFreeUriMembersMmA(&uri, NULL), URI_SUCCESS); +} + +TEST(FreeUriMembersSuite, MultiFreeWorksFine) { + UriUriA uri; + + EXPECT_EQ(uriParseSingleUriA(&uri, "file:///home/user/song.mp3", NULL), + URI_SUCCESS); + + UriUriA uriBackup = uri; + EXPECT_EQ(memcmp(&uriBackup, &uri, sizeof(UriUriA)), 0); + + uriFreeUriMembersA(&uri); + + // Did some pointers change (to NULL)? + EXPECT_NE(memcmp(&uriBackup, &uri, sizeof(UriUriA)), 0); + + uriFreeUriMembersA(&uri); // second time +} + namespace { void testFreeUriMembersFreesHostText(const char *const uriFirst) { // issue #121 const char *const uriAfterLast = uriFirst + strlen(uriFirst); @@ -2255,65 +2255,65 @@ TEST(FreeUriMembersSuite, FreeUriMembersFreesHostTextFuture) { // issue #121 testFreeUriMembersFreesHostText("//[v7.X]"); // arbitrary IPvFuture } -TEST(MakeOwnerSuite, MakeOwner) { - const char * const uriString = "scheme://user:pass@[v7.X]:55555/path/../path/?query#fragment"; - UriUriA uri; - char * uriFirst = strdup(uriString); - const size_t uriLen = strlen(uriFirst); - char * uriAfterLast = uriFirst + uriLen; - - EXPECT_EQ(uriParseSingleUriExA(&uri, uriFirst, uriAfterLast, NULL), URI_SUCCESS); - - // After plain parse, all strings should point inside the original URI string - EXPECT_EQ(uri.owner, URI_FALSE); - URI_EXPECT_RANGE_BETWEEN(uri.scheme, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.userInfo, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.hostText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.hostData.ipFuture, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.portText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.pathHead->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.pathHead->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.pathHead->next->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_EMPTY(uri.pathHead->next->next->next->text); - EXPECT_TRUE(uri.pathHead->next->next->next->next == NULL); - URI_EXPECT_RANGE_BETWEEN(uri.query, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_BETWEEN(uri.fragment, uriFirst, uriAfterLast); - - EXPECT_EQ(uriMakeOwnerA(&uri), URI_SUCCESS); - - // After making owner, *none* of the strings should point inside the original URI string - EXPECT_EQ(uri.owner, URI_TRUE); - URI_EXPECT_RANGE_OUTSIDE(uri.scheme, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.userInfo, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.hostText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.hostData.ipFuture, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.portText, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->next->next->text, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_EMPTY(uri.pathHead->next->next->next->text); - EXPECT_TRUE(uri.pathHead->next->next->next->next == NULL); - URI_EXPECT_RANGE_OUTSIDE(uri.query, uriFirst, uriAfterLast); - URI_EXPECT_RANGE_OUTSIDE(uri.fragment, uriFirst, uriAfterLast); - - // Free originally used memory so we'd get violations on access with ASan - uriAfterLast = NULL; - free(uriFirst); - uriFirst = NULL; - - // Can we recompose the URI without accessing any old freed memory? - int charsRequired; - EXPECT_EQ(uriToStringCharsRequiredA(&uri, &charsRequired), URI_SUCCESS); - EXPECT_TRUE((charsRequired >= 0) && (charsRequired >= static_cast<int>(uriLen))); - char * const uriRemake = new char[charsRequired + 1]; - EXPECT_TRUE(uriRemake != NULL); - EXPECT_EQ(uriToStringA(uriRemake, &uri, charsRequired + 1, NULL), URI_SUCCESS); - EXPECT_TRUE(! strcmp(uriString, uriRemake)); - delete [] uriRemake; - - uriFreeUriMembersA(&uri); -} - +TEST(MakeOwnerSuite, MakeOwner) { + const char * const uriString = "scheme://user:pass@[v7.X]:55555/path/../path/?query#fragment"; + UriUriA uri; + char * uriFirst = strdup(uriString); + const size_t uriLen = strlen(uriFirst); + char * uriAfterLast = uriFirst + uriLen; + + EXPECT_EQ(uriParseSingleUriExA(&uri, uriFirst, uriAfterLast, NULL), URI_SUCCESS); + + // After plain parse, all strings should point inside the original URI string + EXPECT_EQ(uri.owner, URI_FALSE); + URI_EXPECT_RANGE_BETWEEN(uri.scheme, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.userInfo, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.hostText, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.hostData.ipFuture, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.portText, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.pathHead->text, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.pathHead->next->text, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.pathHead->next->next->text, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_EMPTY(uri.pathHead->next->next->next->text); + EXPECT_TRUE(uri.pathHead->next->next->next->next == NULL); + URI_EXPECT_RANGE_BETWEEN(uri.query, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_BETWEEN(uri.fragment, uriFirst, uriAfterLast); + + EXPECT_EQ(uriMakeOwnerA(&uri), URI_SUCCESS); + + // After making owner, *none* of the strings should point inside the original URI string + EXPECT_EQ(uri.owner, URI_TRUE); + URI_EXPECT_RANGE_OUTSIDE(uri.scheme, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.userInfo, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.hostText, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.hostData.ipFuture, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.portText, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->text, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->next->text, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.pathHead->next->next->text, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_EMPTY(uri.pathHead->next->next->next->text); + EXPECT_TRUE(uri.pathHead->next->next->next->next == NULL); + URI_EXPECT_RANGE_OUTSIDE(uri.query, uriFirst, uriAfterLast); + URI_EXPECT_RANGE_OUTSIDE(uri.fragment, uriFirst, uriAfterLast); + + // Free originally used memory so we'd get violations on access with ASan + uriAfterLast = NULL; + free(uriFirst); + uriFirst = NULL; + + // Can we recompose the URI without accessing any old freed memory? + int charsRequired; + EXPECT_EQ(uriToStringCharsRequiredA(&uri, &charsRequired), URI_SUCCESS); + EXPECT_TRUE((charsRequired >= 0) && (charsRequired >= static_cast<int>(uriLen))); + char * const uriRemake = new char[charsRequired + 1]; + EXPECT_TRUE(uriRemake != NULL); + EXPECT_EQ(uriToStringA(uriRemake, &uri, charsRequired + 1, NULL), URI_SUCCESS); + EXPECT_TRUE(! strcmp(uriString, uriRemake)); + delete [] uriRemake; + + uriFreeUriMembersA(&uri); +} + namespace { void testMakeOwnerCopiesHostText(const char *const uriFirst) { // issue #121 const char *const uriAfterLast = uriFirst + strlen(uriFirst); @@ -2349,14 +2349,14 @@ TEST(MakeOwnerSuite, MakeOwnerCopiesHostTextFuture) { // issue #121 testMakeOwnerCopiesHostText("//[v7.X]"); // arbitrary IPvFuture } -TEST(ParseIpFourAddressSuite, FourSaneOctets) { - unsigned char octetOutput[4]; - const char * const ipAddressText = "111.22.3.40"; - const int res = uriParseIpFourAddressA(octetOutput, ipAddressText, - ipAddressText + strlen(ipAddressText)); - EXPECT_EQ(res, URI_SUCCESS); - EXPECT_EQ(octetOutput[0], 111); - EXPECT_EQ(octetOutput[1], 22); - EXPECT_EQ(octetOutput[2], 3); - EXPECT_EQ(octetOutput[3], 40); -} +TEST(ParseIpFourAddressSuite, FourSaneOctets) { + unsigned char octetOutput[4]; + const char * const ipAddressText = "111.22.3.40"; + const int res = uriParseIpFourAddressA(octetOutput, ipAddressText, + ipAddressText + strlen(ipAddressText)); + EXPECT_EQ(res, URI_SUCCESS); + EXPECT_EQ(octetOutput[0], 111); + EXPECT_EQ(octetOutput[1], 22); + EXPECT_EQ(octetOutput[2], 3); + EXPECT_EQ(octetOutput[3], 40); +} diff --git a/contrib/restricted/uriparser/test/ya.make b/contrib/restricted/uriparser/test/ya.make index ae8a32a932..d7ec8635a4 100644 --- a/contrib/restricted/uriparser/test/ya.make +++ b/contrib/restricted/uriparser/test/ya.make @@ -1,38 +1,38 @@ -# Generated by devtools/yamaker. - -GTEST(testrunner) - +# Generated by devtools/yamaker. + +GTEST(testrunner) + OWNER( kikht shindo g:cpp-contrib g:mds ) - + LICENSE( LGPL-2.1-only AND LGPL-2.1-or-later ) - + LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -PEERDIR( +PEERDIR( contrib/restricted/uriparser -) - +) + ADDINCL( contrib/restricted/uriparser ) - -NO_COMPILER_WARNINGS() - -NO_UTIL() - -SRCS( + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( FourSuite.cpp MemoryManagerSuite.cpp VersionSuite.cpp test.cpp -) - -END() +) + +END() diff --git a/contrib/restricted/uriparser/tool/uriparse.c b/contrib/restricted/uriparser/tool/uriparse.c index 027f2d2892..7b4196bd56 100644 --- a/contrib/restricted/uriparser/tool/uriparse.c +++ b/contrib/restricted/uriparser/tool/uriparse.c @@ -5,32 +5,32 @@ * Copyright (C) 2013, Sebastian Pipping <sebastian@pipping.org> * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED @@ -43,10 +43,10 @@ #ifdef _WIN32 # include <winsock2.h> # include <ws2tcpip.h> -# ifdef __MINGW32__ +# ifdef __MINGW32__ WINSOCK_API_LINKAGE const char * WSAAPI inet_ntop( - int af, const void *src, char *dst, socklen_t size); -# endif + int af, const void *src, char *dst, socklen_t size); +# endif #else # include <sys/socket.h> # include <arpa/inet.h> diff --git a/contrib/restricted/uriparser/tool/ya.make b/contrib/restricted/uriparser/tool/ya.make index 3692ca78e5..5b4b806e9f 100644 --- a/contrib/restricted/uriparser/tool/ya.make +++ b/contrib/restricted/uriparser/tool/ya.make @@ -23,7 +23,7 @@ ADDINCL( NO_COMPILER_WARNINGS() -NO_RUNTIME() +NO_RUNTIME() SRCS( uriparse.c diff --git a/contrib/restricted/uriparser/ya.make b/contrib/restricted/uriparser/ya.make index a2b64f8229..204a494748 100644 --- a/contrib/restricted/uriparser/ya.make +++ b/contrib/restricted/uriparser/ya.make @@ -28,13 +28,13 @@ ADDINCL( NO_COMPILER_WARNINGS() -NO_RUNTIME() - -CFLAGS( - -DURI_LIBRARY_BUILD - -DURI_VISIBILITY -) +NO_RUNTIME() +CFLAGS( + -DURI_LIBRARY_BUILD + -DURI_VISIBILITY +) + SRCS( src/UriCommon.c src/UriCompare.c @@ -56,6 +56,6 @@ SRCS( END() RECURSE( - test + test tool ) |