From 91875c4307ea4db68af9f62ea3c2106d3890142a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 5 Dec 2005 16:31:01 +0000 Subject: [PATCH] Check country codes against the list of ccTLD codes, not against the ISO-639-1 codes. Part of a bug fix for Anthill bug #171. --- src/common/chapter_parser_xml.cpp | 5 +++-- src/common/extern_data.cpp | 11 +++++++++++ src/common/extern_data.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/common/chapter_parser_xml.cpp b/src/common/chapter_parser_xml.cpp index d945a46b5..92520e911 100644 --- a/src/common/chapter_parser_xml.cpp +++ b/src/common/chapter_parser_xml.cpp @@ -25,6 +25,7 @@ #include "chapters.h" #include "commonebml.h" #include "error.h" +#include "extern_data.h" #include "iso639.h" #include "mm_io.h" #include "xml_element_mapping.h" @@ -149,8 +150,8 @@ end_chapter_country(void *pdata) { EbmlString *s; s = static_cast(xmlp_pelt); - if (!is_valid_iso639_1_code(string(*s).c_str())) - xmlp_error(CPDATA, "'%s' is not a valid ISO639-1 country code.", + if (!is_valid_cctld(string(*s).c_str())) + xmlp_error(CPDATA, "'%s' is not a valid ccTLD country code.", string(*s).c_str()); } diff --git a/src/common/extern_data.cpp b/src/common/extern_data.cpp index 2388eb895..1dc125871 100644 --- a/src/common/extern_data.cpp +++ b/src/common/extern_data.cpp @@ -2619,3 +2619,14 @@ guess_mime_type(string ext) { return ""; } + +bool +is_valid_cctld(const string &s) { + int i; + + for (i = 0; NULL != cctlds[i]; ++i) + if (s == cctlds[i]) + return true; + + return false; +} diff --git a/src/common/extern_data.h b/src/common/extern_data.h index 0e2de47b9..3ef82bd6e 100644 --- a/src/common/extern_data.h +++ b/src/common/extern_data.h @@ -25,5 +25,6 @@ extern MTX_DLL_API const mime_type_t mime_types[]; extern MTX_DLL_API const char *cctlds[]; string MTX_DLL_API guess_mime_type(string ext); +bool MTX_DLL_API is_valid_cctld(const string &s); #endif // __EXTERN_DATA_H