diff --git a/src/core/l-types.c b/src/core/l-types.c index 3bc235d535..7c5feda6f3 100644 --- a/src/core/l-types.c +++ b/src/core/l-types.c @@ -742,8 +742,9 @@ bad_hex: Trap0(RE_INVALID_CHARS); ** ***********************************************************************/ { - REBYTE *str; REBUNI n; + REBYTE *str = Reset_Buffer(BUF_FORM, len); + REBCNT cnt = len; // !!! Need to check for any possible scheme followed by ':' @@ -753,22 +754,22 @@ bad_hex: Trap0(RE_INVALID_CHARS); // if (n >= URL_MAX) return 0; // if (*str != ':') return 0; - VAL_SERIES(value) = Make_Binary(len); - VAL_INDEX(value) = 0; - - str = VAL_BIN(value); + for (; len > 0; len--) { //if (*cp == '%' && len > 2 && Scan_Hex2(cp+1, &n, FALSE)) { if (*cp == '%') { if (len <= 2 || !Scan_Hex2(cp+1, &n, FALSE)) return 0; *str++ = (REBYTE)n; - cp += 3; + cp += 3; len -= 2; + cnt -= 2; } else *str++ = *cp++; } *str = 0; - VAL_TAIL(value) = (REBCNT)(str - VAL_BIN(value)); + + VAL_SERIES(value) = Decode_UTF_String(BIN_DATA(BUF_FORM), cnt, 8, FALSE); + VAL_INDEX(value) = 0; VAL_SET(value, REB_URL); return cp; } diff --git a/src/tests/units/mold-test.r3 b/src/tests/units/mold-test.r3 index 28143c5045..2074c27a8a 100644 --- a/src/tests/units/mold-test.r3 +++ b/src/tests/units/mold-test.r3 @@ -172,6 +172,26 @@ Rebol [ ===end-group=== +===start-group=== "url" + + --test-- "mold url" + --assert "ftp://" = mold ftp:// + --assert "ftp://š" = mold ftp://š + --assert "ftp://+" = mold ftp://+ + --assert "ftp://+" = mold ftp://%2b + --assert "ftp://+" = mold ftp://%2B + --assert "ftp://%20" = mold ftp://%20 + --test-- "mold append url" + --assert "ftp://a" = mold append ftp:// #"a" + --assert "ftp://a" = mold append ftp:// "a" + --assert "ftp://š" = mold append ftp:// "š" + --assert "ftp://+" = mold append ftp:// "+" + --assert "ftp://%2528" = mold append ftp:// "%28" + --assert "ftp://%28" = dehex mold append ftp:// "%28" + +===end-group=== + + ===start-group=== "mold-all" --test-- "mold-true" --assert "true" = mold true