* or promote products derived from this software without specific prior
* written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * THIS SOFTWARE IS PROVIDED ``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
* AUTHORS OF THIS SOFTWARE 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
+ * 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
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
iri__copychar_decode(char **dest, const char *src, int convert_space)
{
unsigned char *p = (unsigned char *) (*dest);
-
+
if(1 == convert_space && '+' == *src)
{
**dest = ' ';
{
iri_t *p;
char *bufstart, *endp, *bufp, **sl;
- const char *at, *colon, *slash, *t;
+ const char *at, *colon, *slash, *t, *slash3rd;
size_t buflen, sc, cp;
-
+
if(NULL == (p = (iri_t *) calloc(1, sizeof(iri_t))))
{
return NULL;
/* We can disregard the colon if a slash appears before it */
colon = NULL;
}
+ // "@" is valid character in hierarchical part of IRI
+ if(slash && colon && (colon[1] != '/' || colon[2] != '/'))
+ {
+ //if scheme not suffixed with ://, there is not autority
+ //therefore autority(and user within) is not set
+ at = NULL;
+ }
+ else if(at && slash && slash[1] && slash[2])
+ {
+ slash3rd = strchr(slash + 2, '/');
+ //here we know scheme suffix is "://" so autority can exist
+ //3rd slash should match start of hierarchical part if exists
+ //@ after that is valid character
+ if(slash3rd && slash3rd < at)
+ {
+ at = NULL;
+ }
+ }
if(colon && !at)
{
/* Definitely a scheme */
if(*src == '#')
{
bufp = ALIGN(bufp);
- p->iri.anchor = bufp;
+ p->iri.anchor = bufp;
while(*src)
{
src = iri__copychar_decode(&bufp, src, 0);
{
/* Still stuff left? It must be a path... of sorts */
bufp = ALIGN(bufp);
- p->iri.path = bufp;
+ p->iri.path = bufp;
while(*src && *src != '?' && *src != '#')
{
src = iri__copychar_decode(&bufp, src, 0);
--- /dev/null
+#!/bin/bash
+
+PACKAGE_NAME=$1
+PACKAGE_VERSION=$2
+
+TEST_LOG="/tmp/${PACKAGE_NAME}_test"
+export TEST_LOG
+rm -f ${TEST_LOG}
+
+# Color
+Color_Off='\e[0m' # Text Reset
+
+# Regular Colors
+Red='\e[0;31m' # Red
+Green='\e[0;32m' # Green
+Cyan='\e[0;36m' # Cyank
+
+# Bold
+BWhite='\e[1;37m' # White
+
+result_check() {
+ result=$?
+ test_case=$1
+ if [ $result -eq 0 ]
+ then
+ echo -e "${Green}PASS${Color_Off}: $test_case"
+ echo "TEST: PASS: $test_case" >> ${TEST_LOG}
+ else
+ echo -e "${Red}FAIL${Color_Off}: $test_case"
+ echo -e "TEST: FAIL: $test_case" >> ${TEST_LOG}
+ fi
+}
+
+skip_test() {
+ test_case=$1
+ echo -e "${Cyan}SKIP${Color_Off}: $test_case"
+ echo "TEST: SKIP: $test_case" >> ${TEST_LOG}
+}
+
+run_test() {
+ test_case=$1
+ test_arg=$2
+ pushd tests
+ ./${test_case} ${test_arg} > ${test_case}.ref 2>&1
+ diff ${test_case}.ans ${test_case}.ref
+ result_check "diff ${test_case}.ans ${test_case}.ref"
+ popd
+
+}
+
+run_test_sort() {
+ test_case=$1
+ test_arg=$2
+ pushd tests
+ ./${test_case} ${test_arg} 2>&1 | sort > ${test_case}.ref
+ diff ${test_case}.ans ${test_case}.ref
+ result_check "diff ${test_case}.ans ${test_case}.ref"
+ popd
+
+}
+
+ run_test iridump "abc://username:password@example.com:123/path/data?key=value#fragid1"
+
+TOTAL_CNT=`grep "TEST:" ${TEST_LOG} | wc -l`
+PASS_CNT=`grep "PASS:" ${TEST_LOG} | wc -l`
+FAIL_CNT=`grep "FAIL:" ${TEST_LOG} | wc -l`
+SKIP_CNT=`grep "SKIP:" ${TEST_LOG} | wc -l`
+
+
+br='==================='; br=$br$br$br$br;
+
+echo -e "${Green}$br ${Color_Off}"
+echo -e "${Green}Testsuite summary for ${PACKAGE_NAME} ${PACKAGE_VERSION}${Color_Off}"
+echo -e "${Green}$br ${Color_Off}"
+echo -e "#${BWhite} TOTAL: $TOTAL_CNT ${Color_Off}"
+echo -e "#${Green} PASS${Color_Off} : $PASS_CNT"
+echo -e "#${Red} FAIL${Color_Off} : $FAIL_CNT"
+echo -e "#${Cyan} SKIP${Color_Off} : $SKIP_CNT"
+echo -e "${Green}$br ${Color_Off}"
+
+rm -f ${TEST_LOG}
+exit 0
+