Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Verify encoding when importing nfo files #1286

Merged
merged 1 commit into from

1 participant

@mkortstiege
Collaborator

check for valid utf-8 when importing nfo files (closes #13247)

@mkortstiege mkortstiege was assigned
@mkortstiege mkortstiege merged commit e382137 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 4 deletions.
  1. +12 −4 xbmc/NfoFile.h
View
16 xbmc/NfoFile.h
@@ -32,6 +32,7 @@
#include "utils/XBMCTinyXML.h"
#include "addons/Scraper.h"
#include "utils/CharsetConverter.h"
+#include "utils/XMLUtils.h"
class CNfoFile
{
@@ -59,11 +60,18 @@ class CNfoFile
strDoc = document;
else
strDoc = m_headofdoc;
- // try to load using string charset
- if (strDoc.Find("encoding=") == -1)
- g_charsetConverter.unknownToUTF8(strDoc);
- doc.Parse(strDoc.c_str());
+ CStdString encoding;
+ XMLUtils::GetEncoding(&doc, encoding);
+
+ CStdString strUtf8(strDoc);
+ if (encoding.IsEmpty())
+ g_charsetConverter.unknownToUTF8(strUtf8);
+ else
+ g_charsetConverter.stringCharsetToUtf8(encoding, strDoc, strUtf8);
+
+ doc.Clear();
+ doc.Parse(strUtf8.c_str(),0,TIXML_ENCODING_UTF8);
return details.Load(doc.RootElement(), true, prioritise);
}
Something went wrong with that request. Please try again.