From 5e777cbdbedf8830118fdc222929ae0352272896 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Mon, 7 Apr 2014 17:35:47 +0100 Subject: [PATCH] url: fix stupid mistakes in regexp (fixes #2021) --- src/url.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/url.c b/src/url.c index 15ce6f6b..8398b2da 100644 --- a/src/url.c +++ b/src/url.c @@ -98,27 +98,27 @@ urlparse ( const char *str, url_t *url ) #define UC "[a-z0-9_\\-\\.!£$%^&]" #define PC UC #define HC "[a-z0-9\\-\\.]" -#define URL_RE "^([A-Za-z)://(("UC"+)(:("PC"+))?@)?("HC"+)(:([0-9]+))?(/.*)?" +#define URL_RE "^([A-Za-z]+)://(("UC"+)(:("PC"+))?@)?("HC"+)(:([0-9]+))?(/[^\\?]*)?(.([^#]*))?(#(.*))?" int urlparse ( const char *str, url_t *url ) { static regex_t *exp = NULL; - regmatch_t m[12]; + regmatch_t m[16]; char buf[16]; /* Create regexp */ if (!exp) { exp = calloc(1, sizeof(regex_t)); if (regcomp(exp, URL_RE, REG_ICASE | REG_EXTENDED)) { - tvherror("iptv", "failed to compile regexp"); + tvherror("url", "failed to compile regexp"); exit(1); } } /* Execute */ - if (regexec(exp, str, 12, m, 0)) + if (regexec(exp, str, ARRAY_SIZE(m), m, 0)) return 1; /* Extract data */ @@ -137,8 +137,8 @@ urlparse ( const char *str, url_t *url ) copy(url->path, 9); copy(buf, 8); url->port = atoi(buf); - *url->query = 0; - *url->frag = 0; + copy(url->query, 11); + copy(url->frag, 13); strncpy(url->raw, str, sizeof(url->raw));