Skip to content

Instantly share code, notes, and snippets.

@kazeburo
Created January 31, 2014 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazeburo/8727914 to your computer and use it in GitHub Desktop.
Save kazeburo/8727914 to your computer and use it in GitHub Desktop.
diff --git a/XS.xs b/XS.xs
index 4bf4c2a..cbe32bd 100644
--- a/XS.xs
+++ b/XS.xs
@@ -121,13 +121,14 @@ struct _ust {
static void
url_params_each(pTHX_ const char *s, const STRLEN len, const ust_t *u) {
+ static const char sep[] = "&;";
const char *send = s + len;
const char *k, *kend, *v, *vend;
SV *tmpsv = NULL;
bool is_utf8 = FALSE;
while (s < send) {
- if ((vend = (const char *)memchr(s, '&', send - s)) == NULL)
+ if ((vend = (const char *)strpbrk(s, sep)) == NULL)
vend = send;
if ((kend = (const char *)memchr(s, '=', vend - s)) == NULL) {
s = vend + (vend != send);
@@ -135,6 +136,9 @@ url_params_each(pTHX_ const char *s, const STRLEN len, const ust_t *u) {
}
k = s;
+ if ( k[0] == ' ' ) {
+ k++;
+ }
v = kend + 1;
if (u->decode == &url_decode_utf8 || url_encoded(k, kend - k)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment