summaryrefslogtreecommitdiff
path: root/src/fl_load.c
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-05-12 10:22:27 +0200
committerYorhel <git@yorhel.nl>2012-05-12 10:22:27 +0200
commit874ddf797a4f7618533d817f0998bc86315149e7 (patch)
tree667e05a170c955a190f55316bf1bc5e265e6cbe3 /src/fl_load.c
parenta18a975162ede9d575b0e7f5f8c8b8ccc81558c9 (diff)
fl_load.c: Use str_concert() fallback if Name attr is not valid UTF-8
Diffstat (limited to 'src/fl_load.c')
-rw-r--r--src/fl_load.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/fl_load.c b/src/fl_load.c
index 8729473..268ea99 100644
--- a/src/fl_load.c
+++ b/src/fl_load.c
@@ -112,11 +112,7 @@ static int entitycb(void *context, int type, const char *arg1, const char *arg2,
// Handling the attributes of a Directory element.
case S_DIROPEN:
if(type == XMLT_ATTR && strcmp(arg1, "Name") == 0 && !x->name) {
- if(!g_utf8_validate(arg2, -1, NULL)) {
- g_set_error(err, 1, 0, "Invalid UTF-8");
- return -1;
- }
- x->name = g_strdup(arg2);
+ x->name = g_utf8_validate(arg2, -1, NULL) ? g_strdup(arg2) : str_convert("UTF-8", "UTF-8", arg2);
return 0;
}
if(type == XMLT_ATTDONE) {
@@ -175,11 +171,7 @@ static int entitycb(void *context, int type, const char *arg1, const char *arg2,
// attributes with the same name, only the first is used.)
case S_FILEOPEN:
if(type == XMLT_ATTR && strcmp(arg1, "Name") == 0 && !x->name) {
- if(!g_utf8_validate(arg2, -1, NULL)) {
- g_set_error(err, 1, 0, "Invalid UTF-8");
- return -1;
- }
- x->name = g_strdup(arg2);
+ x->name = g_utf8_validate(arg2, -1, NULL) ? g_strdup(arg2) : str_convert("UTF-8", "UTF-8", arg2);
return 0;
}
if(type == XMLT_ATTR && strcmp(arg1, "TTH") == 0 && !x->filehastth) {