+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>
* iri.c : Include missing stringprep.h file and add a
/* sXXXav: could strdupdelim return NULL ? */
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));
return charset;
}
+/* 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;
+}
+
+
char *parse_charset (char *str);
char *find_locale (void);
+bool check_encoding_name (char *encoding);
#else /* ENABLE_IRI */
-#define parse_charset(str) NULL
-#define find_locale() NULL
+#define parse_charset(str) NULL
+#define find_locale() NULL
+#define check_encoding_name(str) false
#endif /* ENABLE_IRI */
#endif /* IRI_H */
#ifdef ENABLE_IRI
if (opt.enable_iri)
{
+ if (opt.locale && !check_encoding_name(opt.locale))
+ opt.locale = NULL;
+
if (!opt.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));
}