diff options
| -rw-r--r-- | scan_urlencoded_query.c | 14 | ||||
| -rw-r--r-- | scan_urlencoded_query.h | 4 |
2 files changed, 6 insertions, 12 deletions
diff --git a/scan_urlencoded_query.c b/scan_urlencoded_query.c index cf0c5b1..4825a4a 100644 --- a/scan_urlencoded_query.c +++ b/scan_urlencoded_query.c | |||
| @@ -170,16 +170,12 @@ size_t fmt_urlencoded(char *dest, const uint8_t *src, size_t len) { | |||
| 170 | 170 | ||
| 171 | /* strchr would find the terminator, so a zero byte never counts as safe */ | 171 | /* strchr would find the terminator, so a zero byte never counts as safe */ |
| 172 | if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c && strchr(safe, c))) { | 172 | if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c && strchr(safe, c))) { |
| 173 | if (dest) | 173 | dest[written++] = (char)c; |
| 174 | dest[written] = (char)c; | ||
| 175 | ++written; | ||
| 176 | } else { | 174 | } else { |
| 177 | if (dest) { | 175 | dest[written] = '%'; |
| 178 | dest[written] = '%'; | 176 | dest[written + 1] = hexdigit[c >> 4]; |
| 179 | dest[written + 1] = hexdigit[c >> 4]; | 177 | dest[written + 2] = hexdigit[c & 15]; |
| 180 | dest[written + 2] = hexdigit[c & 15]; | 178 | written += 3; |
| 181 | } | ||
| 182 | written += 3; | ||
| 183 | } | 179 | } |
| 184 | } | 180 | } |
| 185 | 181 | ||
diff --git a/scan_urlencoded_query.h b/scan_urlencoded_query.h index 6f12c03..d0929cf 100644 --- a/scan_urlencoded_query.h +++ b/scan_urlencoded_query.h | |||
| @@ -55,9 +55,7 @@ void scan_urlencoded_skipvalue(char **string); | |||
| 55 | ssize_t scan_fixed_int(char *data, size_t len, int *number); | 55 | ssize_t scan_fixed_int(char *data, size_t len, int *number); |
| 56 | 56 | ||
| 57 | /* The other direction: percent encode len bytes from src into dest and return | 57 | /* The other direction: percent encode len bytes from src into dest and return |
| 58 | how many characters were written, or how many would be needed when dest is | 58 | how many characters were written. dest needs room for three times len. */ |
| 59 | NULL. dest needs room for three times len. | ||
| 60 | */ | ||
| 61 | size_t fmt_urlencoded(char *dest, const uint8_t *src, size_t len); | 59 | size_t fmt_urlencoded(char *dest, const uint8_t *src, size_t len); |
| 62 | 60 | ||
| 63 | #endif | 61 | #endif |
