mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Introduce a new function check_encoding_name() for doing a basic check on encoding name validity
This commit is contained in:
parent
be546c20cb
commit
e6376b4743
@ -1,3 +1,10 @@
|
|||||||
|
2008-06-19 Xavier Saint <wget@sxav.eu>
|
||||||
|
|
||||||
|
* iri.c, iri.h : New function check_encoding_name() as
|
||||||
|
a priliminary encoding name check.
|
||||||
|
|
||||||
|
* main.c, iri.c : Make use of check_encoding_name().
|
||||||
|
|
||||||
2008-06-19 Xavier Saint <wget@sxav.eu>
|
2008-06-19 Xavier Saint <wget@sxav.eu>
|
||||||
|
|
||||||
* iri.c : Include missing stringprep.h file and add a
|
* iri.c : Include missing stringprep.h file and add a
|
||||||
|
29
src/iri.c
29
src/iri.c
@ -64,6 +64,14 @@ parse_charset (char *str)
|
|||||||
|
|
||||||
/* sXXXav: could strdupdelim return NULL ? */
|
/* sXXXav: could strdupdelim return NULL ? */
|
||||||
charset = strdupdelim (str, charset);
|
charset = strdupdelim (str, charset);
|
||||||
|
|
||||||
|
/* Do a minimum check on the charset value */
|
||||||
|
if (!check_encoding_name (charset))
|
||||||
|
{
|
||||||
|
xfree (charset);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
logprintf (LOG_VERBOSE, "parse_charset: %s\n", quote (charset));
|
logprintf (LOG_VERBOSE, "parse_charset: %s\n", quote (charset));
|
||||||
|
|
||||||
return charset;
|
return charset;
|
||||||
@ -79,3 +87,24 @@ find_locale (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Basic check of an encoding name. */
|
||||||
|
bool
|
||||||
|
check_encoding_name (char *encoding)
|
||||||
|
{
|
||||||
|
char *s = encoding;
|
||||||
|
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
if (!c_isascii(*s) || c_isspace(*s))
|
||||||
|
{
|
||||||
|
logprintf (LOG_VERBOSE, "Encoding %s isn't valid\n", quote(encoding));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,11 +34,13 @@ as that of the covered work. */
|
|||||||
|
|
||||||
char *parse_charset (char *str);
|
char *parse_charset (char *str);
|
||||||
char *find_locale (void);
|
char *find_locale (void);
|
||||||
|
bool check_encoding_name (char *encoding);
|
||||||
|
|
||||||
#else /* ENABLE_IRI */
|
#else /* ENABLE_IRI */
|
||||||
|
|
||||||
#define parse_charset(str) NULL
|
#define parse_charset(str) NULL
|
||||||
#define find_locale() NULL
|
#define find_locale() NULL
|
||||||
|
#define check_encoding_name(str) false
|
||||||
|
|
||||||
#endif /* ENABLE_IRI */
|
#endif /* ENABLE_IRI */
|
||||||
#endif /* IRI_H */
|
#endif /* IRI_H */
|
||||||
|
@ -1067,10 +1067,14 @@ for details.\n\n"));
|
|||||||
#ifdef ENABLE_IRI
|
#ifdef ENABLE_IRI
|
||||||
if (opt.enable_iri)
|
if (opt.enable_iri)
|
||||||
{
|
{
|
||||||
|
if (opt.locale && !check_encoding_name(opt.locale))
|
||||||
|
opt.locale = NULL;
|
||||||
|
|
||||||
if (!opt.locale)
|
if (!opt.locale)
|
||||||
opt.locale = find_locale ();
|
opt.locale = find_locale ();
|
||||||
|
|
||||||
/* sXXXav : check given locale and remote encoding */
|
if (opt.encoding_remote && !check_encoding_name(opt.encoding_remote))
|
||||||
|
opt.encoding_remote = NULL;
|
||||||
|
|
||||||
logprintf (LOG_VERBOSE, "Locale = %s\n", quote (opt.locale));
|
logprintf (LOG_VERBOSE, "Locale = %s\n", quote (opt.locale));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user