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.

This commit is contained in:
Moritz Bunkus 2005-12-05 16:31:01 +00:00
parent 4b1d293400
commit 91875c4307
3 changed files with 15 additions and 2 deletions

View File

@ -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<EbmlString *>(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());
}

View File

@ -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;
}

View File

@ -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