%XX escape any input out of range as defined in RFC3986, and also if PATH, convert all path separators to '/'. */
| 4666 | /* %XX escape any input out of range as defined in RFC3986, |
| 4667 | and also if PATH, convert all path separators to '/'. */ |
| 4668 | static char * |
| 4669 | file_escape (char const *str, bool path) |
| 4670 | { |
| 4671 | char *esc = xnmalloc (3, strlen (str) + 1); |
| 4672 | char *p = esc; |
| 4673 | while (*str) |
| 4674 | { |
| 4675 | if (path && ISSLASH (*str)) |
| 4676 | { |
| 4677 | *p++ = '/'; |
| 4678 | str++; |
| 4679 | } |
| 4680 | else if (RFC3986[to_uchar (*str)]) |
| 4681 | *p++ = *str++; |
| 4682 | else |
| 4683 | p += sprintf (p, "%%%02x", to_uchar (*str++)); |
| 4684 | } |
| 4685 | *p = '\0'; |
| 4686 | return esc; |
| 4687 | } |
| 4688 | |
| 4689 | static size_t |
| 4690 | quote_name (char const *name, struct quoting_options const *options, |
no test coverage detected