[tracker] Handle single null terminated strings in UCS2 and UTF-16 in mp3 extractor



commit a4c6c4b685a087851b9312e43de3c0997ff52448
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Fri May 14 05:54:14 2010 +0300

    Handle single null terminated strings in UCS2 and UTF-16 in mp3 extractor

 src/tracker-extract/tracker-extract-mp3.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 65155f6..09d9663 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -994,7 +994,8 @@ id3v24_text_to_utf8 (const gchar  encoding,
 {
 	/* This byte describes the encoding
 	 * try to convert strings to UTF-8
-	 * if it fails, then forget it
+	 * if it fails, then forget it.
+	 * For UTF-16 if size odd assume invalid 00 term.
 	 */
 
 	switch (encoding) {
@@ -1006,13 +1007,13 @@ id3v24_text_to_utf8 (const gchar  encoding,
 		                            NULL, NULL, NULL);
 	case 0x01 :
 		return convert_to_encoding (text,
-		                            len,
+		                            len - len%2,
 		                            "UTF-8",
 		                            "UTF-16",
 		                            NULL, NULL, NULL);
 	case 0x02 :
 		return convert_to_encoding (text,
-		                            len,
+		                            len - len%2,
 		                            "UTF-8",
 		                            "UTF-16BE",
 		                            NULL, NULL, NULL);
@@ -1040,6 +1041,7 @@ id3v2_text_to_utf8 (const gchar  encoding,
 	/* This byte describes the encoding
 	 * try to convert strings to UTF-8
 	 * if it fails, then forget it
+	 * For UCS2 if size odd assume invalid 00 term.
 	 */
 
 	switch (encoding) {
@@ -1055,7 +1057,7 @@ id3v2_text_to_utf8 (const gchar  encoding,
 		/*                                "UTF-8", */
 		/*                                "UCS-2", */
 		/*                                NULL, NULL, NULL); */
-		return ucs2_to_utf8 (text, len);
+		return ucs2_to_utf8 (text, len - len%2);
 
 	default:
 		/* Bad encoding byte,
@@ -1249,6 +1251,8 @@ get_id3v24_tags (const gchar          *data,
 				g_strstrip (word);
 			}
 
+			g_debug ("Frame is %d, word is %s", frame, word);
+
 			switch (frame) {
 			case ID3V24_TALB:
 				tag->album = word;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]