@@ -321,10 +321,12 @@ int av_match_name(const char *name, const char *names);
char *av_append_path_component(const char *path, const char *component);
enum AVEscapeMode {
- AV_ESCAPE_MODE_AUTO, ///< Use auto-selected escaping mode.
- AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
- AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.
- AV_ESCAPE_MODE_XML_CHAR_DATA, ///< Use XML non-markup character data escaping.
+ AV_ESCAPE_MODE_AUTO, ///< Use auto-selected escaping mode.
+ AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
+ AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.
+ AV_ESCAPE_MODE_XML_CHAR_DATA, ///< Use XML non-markup character data escaping.
+ AV_ESCAPE_MODE_XML_ATT_VALUE_SINGLE_QUOTED, ///< Use XML single quoted attribute value escaping.
+ AV_ESCAPE_MODE_XML_ATT_VALUE_DOUBLE_QUOTED, ///< Use XML double quoted attribute value escaping.
};
/**
@@ -298,6 +298,32 @@ void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_cha
}
break;
+ case AV_ESCAPE_MODE_XML_ATT_VALUE_SINGLE_QUOTED:
+ /* escape XML single quoted attribute values as per 2.3 */
+ /* "'" ([^<&'] | Reference)* "'" */
+ for (; *src; src++) {
+ switch (*src) {
+ case '&' : av_bprintf(dstbuf, "%s", "&"); break;
+ case '<' : av_bprintf(dstbuf, "%s", "<"); break;
+ case '\'': av_bprintf(dstbuf, "%s", "'"); break;
+ default: av_bprint_chars(dstbuf, *src, 1);
+ }
+ }
+ break;
+
+ case AV_ESCAPE_MODE_XML_ATT_VALUE_DOUBLE_QUOTED:
+ /* escape XML double quoted attribute values as per 2.3 */
+ /* '"' ([^<&"] | Reference)* '"' */
+ for (; *src; src++) {
+ switch (*src) {
+ case '&' : av_bprintf(dstbuf, "%s", "&"); break;
+ case '<' : av_bprintf(dstbuf, "%s", "<"); break;
+ case '"' : av_bprintf(dstbuf, "%s", """); break;
+ default: av_bprint_chars(dstbuf, *src, 1);
+ }
+ }
+ break;
+
/* case AV_ESCAPE_MODE_BACKSLASH or unknown mode */
default:
/* \-escape characters */
@@ -101,10 +101,12 @@ int main(int argc, char **argv)
break;
}
case 'm':
- if (!strcmp(optarg, "auto")) escape_mode = AV_ESCAPE_MODE_AUTO;
- else if (!strcmp(optarg, "backslash")) escape_mode = AV_ESCAPE_MODE_BACKSLASH;
- else if (!strcmp(optarg, "quote")) escape_mode = AV_ESCAPE_MODE_QUOTE;
- else if (!strcmp(optarg, "xml_char_data")) escape_mode = AV_ESCAPE_MODE_XML_CHAR_DATA;
+ if (!strcmp(optarg, "auto")) escape_mode = AV_ESCAPE_MODE_AUTO;
+ else if (!strcmp(optarg, "backslash")) escape_mode = AV_ESCAPE_MODE_BACKSLASH;
+ else if (!strcmp(optarg, "quote")) escape_mode = AV_ESCAPE_MODE_QUOTE;
+ else if (!strcmp(optarg, "xml_char_data")) escape_mode = AV_ESCAPE_MODE_XML_CHAR_DATA;
+ else if (!strcmp(optarg, "xml_att_value_single_quoted")) escape_mode = AV_ESCAPE_MODE_XML_ATT_VALUE_SINGLE_QUOTED;
+ else if (!strcmp(optarg, "xml_att_value_double_quoted")) escape_mode = AV_ESCAPE_MODE_XML_ATT_VALUE_DOUBLE_QUOTED;
else {
av_log(NULL, AV_LOG_ERROR,
"Invalid value '%s' for option -m, "