[PATCH] shlwapi: implement URL_ESCAPE_AS_UTF8

Alexandre Julliard julliard at winehq.org
Wed Dec 23 02:22:24 CST 2015


Daniel Lehman <dlehman at esri.com> writes:

> @@ -925,6 +955,20 @@ static void test_UrlEscapeW(void)
>          FreeWideString(urlW);
>          FreeWideString(expected_urlW);
>      }
> +
> +    for(i=0; i<sizeof(TEST_ESCAPEW)/sizeof(TEST_ESCAPEW[0]); i++) {
> +        WCHAR ret_url[INTERNET_MAX_URL_LENGTH];
> +
> +        size = INTERNET_MAX_URL_LENGTH;
> +        ret = pUrlEscapeW(TEST_ESCAPEW[i].url, ret_url, &size, TEST_ESCAPEW[i].flags);
> +        if(ret == E_POINTER || TEST_ESCAPEW[i].broken) /* <= Win7/Win2k8 */
> +            continue;

That's not going to test anything for the broken cases.

> @@ -1188,10 +1194,29 @@ HRESULT WINAPI UrlEscapeW(
>              if(cur == '\\' && (int_flags & WINE_URL_BASH_AS_SLASH) && !stop_escaping) cur = '/';
>  
>              if(URL_NeedEscapeW(cur, dwFlags, int_flags) && stop_escaping == FALSE) {
> -                next[0] = '%';
> -                next[1] = hexDigits[(cur >> 4) & 0xf];
> -                next[2] = hexDigits[cur & 0xf];
> -                len = 3;
> +                if(dwFlags & URL_ESCAPE_AS_UTF8) {
> +                    char utf[4];
> +                    int i, ret;
> +                    ret = wine_utf8_wcstombs(WC_ERR_INVALID_CHARS, &cur, 1, utf, sizeof(utf));

This won't work for Unicode surrogates.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list