totem-pl-parser r310 - in trunk: . plparse
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: totem-pl-parser r310 - in trunk: . plparse
- Date: Tue, 17 Feb 2009 11:22:07 +0000 (UTC)
Author: hadess
Date: Tue Feb 17 11:22:07 2009
New Revision: 310
URL: http://svn.gnome.org/viewvc/totem-pl-parser?rev=310&view=rev
Log:
2009-02-17 Bastien Nocera <hadess hadess net>
* plparse/totem-pl-parser-pls.c (ensure_utf8_valid),
(totem_pl_parser_add_pls_with_contents): Patch from
Ivan Frade <ivan frade nokia com> to avoid crashing
when a PLS file contains non-UTF-8 characters
(Closes: #568736)
Modified:
trunk/ChangeLog
trunk/plparse/totem-pl-parser-pls.c
Modified: trunk/plparse/totem-pl-parser-pls.c
==============================================================================
--- trunk/plparse/totem-pl-parser-pls.c (original)
+++ trunk/plparse/totem-pl-parser-pls.c Tue Feb 17 11:22:07 2009
@@ -122,6 +122,27 @@
return TRUE;
}
+static char *
+ensure_utf8_valid (char *input)
+{
+ char *utf8_valid;
+
+ utf8_valid = g_strdup (input);
+
+ if (!g_utf8_validate (utf8_valid, -1, NULL)) {
+ gint i;
+
+ for (i = 0; i < g_utf8_strlen (utf8_valid, -1); i++) {
+ gunichar c;
+ c = g_utf8_get_char_validated (&utf8_valid[i], -1);
+ if (c > 127) {
+ utf8_valid[i] = '?';
+ }
+ }
+ }
+ return utf8_valid;
+}
+
TotemPlParserResult
totem_pl_parser_add_pls_with_contents (TotemPlParser *parser,
GFile *file,
@@ -249,11 +270,13 @@
g_object_unref (target);
} else {
GFile *target;
+ char *utf8_filename;
- target = g_file_get_child_for_display_name (base_file, file_str, NULL);
+ utf8_filename = ensure_utf8_valid (file_str);
+ target = g_file_get_child_for_display_name (base_file, utf8_filename, NULL);
+ g_free (utf8_filename);
if (length_num < 0 || totem_pl_parser_parse_internal (parser, target, base_file) != TOTEM_PL_PARSER_RESULT_SUCCESS) {
-
totem_pl_parser_add_uri (parser,
TOTEM_PL_PARSER_FIELD_FILE, target,
TOTEM_PL_PARSER_FIELD_TITLE, title,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]