summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormethodus <methodus@web.de>2012-11-01 17:32:20 +0100
committermethodus <methodus@web.de>2012-11-01 17:32:20 +0100
commit5824caa0b76686cc4cdacba9cec34b31fb70ba4a (patch)
treedd40e99c0b0094f19f43a612910d0c3ffef13d64
parent9d9684f5bcfaabd05f4d41b0c7d2a35d7b1a489c (diff)
downloadvdr-plugin-upnp-5824caa0b76686cc4cdacba9cec34b31fb70ba4a.tar.gz
vdr-plugin-upnp-5824caa0b76686cc4cdacba9cec34b31fb70ba4a.tar.bz2
Escape XML special chars in DIDL
-rw-r--r--common/ixml.cpp4
-rw-r--r--include/tools/ixml.h2
-rw-r--r--media/mediaManager.cpp16
3 files changed, 15 insertions, 7 deletions
diff --git a/common/ixml.cpp b/common/ixml.cpp
index f463124..6a33daf 100644
--- a/common/ixml.cpp
+++ b/common/ixml.cpp
@@ -11,7 +11,7 @@ namespace upnp {
namespace ixml {
-void XmlEscapeSpecialChars(string& doc){
+string& XmlEscapeSpecialChars(string& doc){
std::string buffer;
buffer.reserve(doc.size()*1.1);
@@ -121,6 +121,8 @@ void XmlEscapeSpecialChars(string& doc){
}
doc.swap(buffer);
+
+ return doc;
}
//Function copied from Intel SDK
diff --git a/include/tools/ixml.h b/include/tools/ixml.h
index 737c753..ffc0fca 100644
--- a/include/tools/ixml.h
+++ b/include/tools/ixml.h
@@ -18,7 +18,7 @@ namespace upnp {
namespace ixml {
- void XmlEscapeSpecialChars(string& doc);
+ string& XmlEscapeSpecialChars(string& doc);
/**
* First occurance of item
*
diff --git a/media/mediaManager.cpp b/media/mediaManager.cpp
index 5bd02eb..de87aa6 100644
--- a/media/mediaManager.cpp
+++ b/media/mediaManager.cpp
@@ -305,22 +305,28 @@ int cMediaManager::CreateResponse(MediaRequest& request, const string& select, c
ixml::IxmlAddProperty(DIDLDoc, object, property::object::KEY_OBJECTID, objectID);
ixml::IxmlAddProperty(DIDLDoc, object, property::object::KEY_PARENTID, row.getString(property::object::KEY_PARENTID));
ixml::IxmlAddProperty(DIDLDoc, object, property::object::KEY_RESTRICTED, row.getString(property::object::KEY_RESTRICTED));
- ixml::IxmlAddProperty(DIDLDoc, object, property::object::KEY_TITLE, row.getString(property::object::KEY_TITLE).substr(0, MAX_METADATA_LENGTH_S));
+
+ string title = row.getString(property::object::KEY_TITLE).substr(0, MAX_METADATA_LENGTH_S);
+ ixml::IxmlAddProperty(DIDLDoc, object, property::object::KEY_TITLE, ixml::XmlEscapeSpecialChars(title));
ixml::IxmlAddProperty(DIDLDoc, object, property::object::KEY_CLASS, row.getString(property::object::KEY_CLASS).substr(0, MAX_METADATA_LENGTH_S));
if(isContainer){
ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_CHILD_COUNT, row.getString(property::object::KEY_CHILD_COUNT));
}
else {
+ string channelName = row.getString(property::object::KEY_CHANNEL_NAME);
ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_CHANNEL_NR, row.getString(property::object::KEY_CHANNEL_NR));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_CHANNEL_NAME, row.getString(property::object::KEY_CHANNEL_NAME));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_CHANNEL_NAME, ixml::XmlEscapeSpecialChars(channelName));
ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_SCHEDULED_START, row.getString(property::object::KEY_SCHEDULED_START));
ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_SCHEDULED_END, row.getString(property::object::KEY_SCHEDULED_END));
}
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_CREATOR, row.getString(property::object::KEY_CREATOR));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_DESCRIPTION, row.getString(property::object::KEY_DESCRIPTION));
- ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_LONG_DESCRIPTION, row.getString(property::object::KEY_LONG_DESCRIPTION));
+ string creator = row.getString(property::object::KEY_CREATOR);
+ string description = row.getString(property::object::KEY_DESCRIPTION);
+ string longDescription = row.getString(property::object::KEY_LONG_DESCRIPTION);
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_CREATOR, ixml::XmlEscapeSpecialChars(creator));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_DESCRIPTION, ixml::XmlEscapeSpecialChars(description));
+ ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_LONG_DESCRIPTION, ixml::XmlEscapeSpecialChars(longDescription));
ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_DATE, row.getString(property::object::KEY_DATE));
ixml::IxmlAddFilteredProperty(filterList, DIDLDoc, object, property::object::KEY_LANGUAGE, row.getString(property::object::KEY_LANGUAGE));