mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
Moved the XML node name creation function into common.cpp. Escape the contents the XML way before putting them into CodecPrivate or the data blocks.
This commit is contained in:
parent
cbe0a25c38
commit
b034ec2188
@ -908,6 +908,21 @@ escape_xml(const string &source,
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
create_xml_node_name(const char *name,
|
||||||
|
const char **atts) {
|
||||||
|
int i;
|
||||||
|
string node_name;
|
||||||
|
|
||||||
|
node_name = string("<") + name;
|
||||||
|
for (i = 0; (NULL != atts[i]) && (NULL != atts[i + 1]); i += 2)
|
||||||
|
node_name += string(" ") + atts[i] + "=\"" +
|
||||||
|
escape_xml(atts[i + 1], true) + "\"";
|
||||||
|
node_name += ">";
|
||||||
|
|
||||||
|
return node_name;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
starts_with(const string &s,
|
starts_with(const string &s,
|
||||||
const char *start,
|
const char *start,
|
||||||
|
@ -225,8 +225,9 @@ string MTX_DLL_API join(const char *pattern, vector<string> &strings);
|
|||||||
void MTX_DLL_API strip(string &s, bool newlines = false);
|
void MTX_DLL_API strip(string &s, bool newlines = false);
|
||||||
void MTX_DLL_API strip(vector<string> &v, bool newlines = false);
|
void MTX_DLL_API strip(vector<string> &v, bool newlines = false);
|
||||||
string MTX_DLL_API escape(const string &src);
|
string MTX_DLL_API escape(const string &src);
|
||||||
string MTX_DLL_API escape_xml(const string &src, bool escape_quotes = false);
|
|
||||||
string MTX_DLL_API unescape(const string &src);
|
string MTX_DLL_API unescape(const string &src);
|
||||||
|
string MTX_DLL_API escape_xml(const string &src, bool escape_quotes = false);
|
||||||
|
string MTX_DLL_API create_xml_node_name(const char *name, const char **atts);
|
||||||
bool MTX_DLL_API starts_with(const string &s, const char *start,
|
bool MTX_DLL_API starts_with(const string &s, const char *start,
|
||||||
int maxlen = -1);
|
int maxlen = -1);
|
||||||
inline bool
|
inline bool
|
||||||
|
@ -158,21 +158,6 @@ usf_reader_c::~usf_reader_c() {
|
|||||||
XML_ParserFree(m_parser);
|
XML_ParserFree(m_parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
|
||||||
usf_reader_c::create_node_name(const char *name,
|
|
||||||
const char **atts) {
|
|
||||||
int i;
|
|
||||||
string node_name;
|
|
||||||
|
|
||||||
node_name = string("<") + name;
|
|
||||||
for (i = 0; (NULL != atts[i]) && (NULL != atts[i + 1]); i += 2)
|
|
||||||
node_name += string(" ") + atts[i] + "=\"" +
|
|
||||||
escape_xml(atts[i + 1], true) + "\"";
|
|
||||||
node_name += ">";
|
|
||||||
|
|
||||||
return node_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
usf_reader_c::start_cb(const char *name,
|
usf_reader_c::start_cb(const char *name,
|
||||||
const char **atts) {
|
const char **atts) {
|
||||||
@ -190,7 +175,8 @@ usf_reader_c::start_cb(const char *name,
|
|||||||
// Just copy the data.
|
// Just copy the data.
|
||||||
if (m_strip)
|
if (m_strip)
|
||||||
strip(m_data_buffer);
|
strip(m_data_buffer);
|
||||||
m_copy_buffer += m_data_buffer + create_node_name(name, atts);
|
m_copy_buffer += escape_xml(m_data_buffer) +
|
||||||
|
create_xml_node_name(name, atts);
|
||||||
++m_copy_depth;
|
++m_copy_depth;
|
||||||
m_data_buffer = "";
|
m_data_buffer = "";
|
||||||
|
|
||||||
@ -254,7 +240,8 @@ usf_reader_c::start_cb(const char *name,
|
|||||||
} else if (m_parents.size() == 2) {
|
} else if (m_parents.size() == 2) {
|
||||||
m_copy_depth = 1;
|
m_copy_depth = 1;
|
||||||
strip(m_data_buffer);
|
strip(m_data_buffer);
|
||||||
m_copy_buffer = m_data_buffer + create_node_name(name, atts);
|
m_copy_buffer = escape_xml(m_data_buffer) +
|
||||||
|
create_xml_node_name(name, atts);
|
||||||
m_strip = true;
|
m_strip = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -285,7 +272,7 @@ usf_reader_c::end_cb(const char *name) {
|
|||||||
m_copy_buffer.erase(m_copy_buffer.length() - 1);
|
m_copy_buffer.erase(m_copy_buffer.length() - 1);
|
||||||
m_copy_buffer += "/>";
|
m_copy_buffer += "/>";
|
||||||
} else
|
} else
|
||||||
m_copy_buffer += m_data_buffer + "</" + name + ">";
|
m_copy_buffer += escape_xml(m_data_buffer) + "</" + name + ">";
|
||||||
--m_copy_depth;
|
--m_copy_depth;
|
||||||
|
|
||||||
if (0 == m_copy_depth) {
|
if (0 == m_copy_depth) {
|
||||||
|
@ -87,7 +87,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
virtual int64_t parse_timecode(const char *s);
|
virtual int64_t parse_timecode(const char *s);
|
||||||
virtual string create_node_name(const char *name, const char **atts);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __R_USF_H
|
#endif // __R_USF_H
|
||||||
|
Loading…
Reference in New Issue
Block a user