Do we need to unescape if it's not a file:// url?I was hoping we could find some IUri/path API flags to do what we need for us.
Another concern is path/url max lengths are used seemingly randomly, and it's not a problem with your change, but with existing code.I think asking for required length and allocating it is better.
- /* Regular local path with some URL encoded characters. */
- strcpy(path2, path);
- n = strlen(path2);
- path2[n-1] = '%';
- path2[n] = '6';
- path2[n+1] = 'C';
- path2[n+2] = '\0'; /* C:\path\to\winetest.xm%6C */
- test_doc_load_from_path(doc, path2);
Could you make this more readable? Maybe strcat-ing escaped file name as string literal instead.
- /* Regular local path with all URL encoded characters. */
- percent_path = HeapAlloc(GetProcessHeap(), 0, 3*n + 1);
- for (i = 0; i < n; i++)
- {
static char hex_tab[] = "0123456789ABCDEF";
percent_path[3*i] = '%';
percent_path[3*i + 1] = hex_tab[path[i] >> 4];
percent_path[3*i + 2] = hex_tab[path[i] & 0xF];
- }
- percent_path[3*n] = '\0';
- test_doc_load_from_path(doc, percent_path);
- HeapFree(GetProcessHeap(), 0, percent_path);
Couple of cases would be enough, like you did earlier for "l" -> %6c, and another one for " " -> %20. Space is actually not tested by this patch, and that's what application is using. If you still want to encode it entirely, please add a helper function.