From f80810f3a2aa5bacc670c214b4c345ac4421aa65 Mon Sep 17 00:00:00 2001 From: codestation Date: Tue, 17 Dec 2013 20:41:13 -0430 Subject: [PATCH] Fix the CMA crash on the PS Vita because it expects xml files that doesn't follow the spec o_O --- src/cmaobject.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cmaobject.cpp b/src/cmaobject.cpp index a041b92..da48e85 100644 --- a/src/cmaobject.cpp +++ b/src/cmaobject.cpp @@ -87,7 +87,23 @@ void CMAObject::loadSfoMetadata(const QString &path) if(reader.load(sfo)) { metadata.data.saveData.title = strdup(reader.value("TITLE", "")); - metadata.data.saveData.detail = strdup(reader.value("SAVEDATA_DETAIL", "")); + QString detail(reader.value("SAVEDATA_DETAIL", "")); + + // libxml follow the spec and normalizes the newlines (and others) but + // the PS Vita chokes on contiguous codes and crashes the CMA app on + // the device. Of course, the "fix" would be that libxml doesn't + // normalize newlines but that is aganist the XML spec that the PS Vita + // doesn't respect >_> + + // convert DOS to UNIX newlines + detail.replace("\r\n", "\n"); + // separate newlines from quotes + detail.replace("\n\"", "\n \""); + detail.replace("\"\n", "\" \n"); + // merge consecutive newlines + detail.replace("\n\n", "\n"); + + metadata.data.saveData.detail = strdup(detail.toStdString().c_str()); metadata.data.saveData.savedataTitle = strdup(reader.value("SAVEDATA_TITLE", "")); metadata.data.saveData.dateTimeUpdated = QFileInfo(sfo).created().toTime_t(); } else {