mirror of
https://github.com/moparisthebest/curl
synced 2024-11-11 20:15:03 -05:00
glob: fix regression from commit 5ca96cb844
Plain strings after glob ranges/lists weren't treated correctly but caused broken URLs to get used. Reported-by: Javier Barroso
This commit is contained in:
parent
be31924f8c
commit
867b52a7ac
@ -40,7 +40,8 @@ typedef enum {
|
|||||||
|
|
||||||
void glob_cleanup(URLGlob* glob);
|
void glob_cleanup(URLGlob* glob);
|
||||||
|
|
||||||
static GlobCode glob_fixed(URLGlob *glob, unsigned long *amount)
|
static GlobCode glob_fixed(URLGlob *glob, unsigned long *amount,
|
||||||
|
char *fixed, size_t len)
|
||||||
{
|
{
|
||||||
URLPattern *pat = &glob->pattern[glob->size];
|
URLPattern *pat = &glob->pattern[glob->size];
|
||||||
pat->type = UPTSet;
|
pat->type = UPTSet;
|
||||||
@ -55,10 +56,13 @@ static GlobCode glob_fixed(URLGlob *glob, unsigned long *amount)
|
|||||||
if(!pat->content.Set.elements)
|
if(!pat->content.Set.elements)
|
||||||
return GLOBERROR("out of memory", 0, GLOB_NO_MEM);
|
return GLOBERROR("out of memory", 0, GLOB_NO_MEM);
|
||||||
|
|
||||||
pat->content.Set.elements[0] = strdup(glob->glob_buffer);
|
pat->content.Set.elements[0] = malloc(len+1);
|
||||||
if(!pat->content.Set.elements[0])
|
if(!pat->content.Set.elements[0])
|
||||||
return GLOBERROR("out of memory", 0, GLOB_NO_MEM);
|
return GLOBERROR("out of memory", 0, GLOB_NO_MEM);
|
||||||
|
|
||||||
|
memcpy(pat->content.Set.elements[0], fixed, len);
|
||||||
|
pat->content.Set.elements[0][len] = 0;
|
||||||
|
|
||||||
return GLOB_OK;
|
return GLOB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,11 +311,11 @@ static GlobCode glob_parse(URLGlob *glob, char *pattern,
|
|||||||
/* processes a literal string component of a URL
|
/* processes a literal string component of a URL
|
||||||
special characters '{' and '[' branch to set/range processing functions
|
special characters '{' and '[' branch to set/range processing functions
|
||||||
*/
|
*/
|
||||||
char* buf = glob->glob_buffer;
|
|
||||||
GlobCode res = GLOB_OK;
|
GlobCode res = GLOB_OK;
|
||||||
int globindex = 0; /* count "actual" globs */
|
int globindex = 0; /* count "actual" globs */
|
||||||
|
|
||||||
while(*pattern && !res) {
|
while(*pattern && !res) {
|
||||||
|
char *buf = glob->glob_buffer;
|
||||||
int sublen = 0;
|
int sublen = 0;
|
||||||
while(*pattern && *pattern != '{' && *pattern != '[') {
|
while(*pattern && *pattern != '{' && *pattern != '[') {
|
||||||
if(*pattern == '}' || *pattern == ']')
|
if(*pattern == '}' || *pattern == ']')
|
||||||
@ -333,7 +337,7 @@ static GlobCode glob_parse(URLGlob *glob, char *pattern,
|
|||||||
if(sublen) {
|
if(sublen) {
|
||||||
/* we got a literal string, add it as a single-item list */
|
/* we got a literal string, add it as a single-item list */
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
res = glob_fixed(glob, amount);
|
res = glob_fixed(glob, amount, glob->glob_buffer, sublen);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!*amount)
|
if(!*amount)
|
||||||
|
Loading…
Reference in New Issue
Block a user