]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Respect ITS escape rule for attributes
authorDaiki Ueno <ueno@gnu.org>
Thu, 10 Dec 2015 07:34:52 +0000 (16:34 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 10 Dec 2015 07:36:59 +0000 (16:36 +0900)
* gettext-tools/src/its.c (its_rule_list_extract_text): Check for
"escape" value for an attribute node.
* gettext-tools/tests/xgettext-its-1: Add tests for gt:escapeRule.

gettext-tools/src/its.c
gettext-tools/tests/xgettext-its-1

index 394b5f06dc11c72f71c2d1cdb68bee649df03550..a1d78431dcae3971166377631fca7c368cbdecde 100644 (file)
@@ -1661,10 +1661,13 @@ its_rule_list_extract_text (its_rule_list_ty *rules,
         comment = xstrdup (value);
       else
         {
+          value = its_value_list_get_value (values, "escape");
+          no_escape = value != NULL && strcmp (value, "no") == 0;
+
           value = its_value_list_get_value (values, "locNotePointer");
           if (value)
             comment = _its_get_content (rules, node, value, ITS_WHITESPACE_TRIM,
-                                        false);
+                                        no_escape);
         }
 
       if (comment != NULL && *comment != '\0')
index 26a149cb91f8c792bc438772dbb53b4ec1c4e863..9e3cac51d8c93fc8d26b7474c8a44f85ad4763e2 100755 (executable)
@@ -99,6 +99,11 @@ cat <<\EOF > its/messages.its
   <gt:contextRule selector="//msg:p[@context = 'yes']"
                   contextPointer="substring-before(., '|')"
                   textPointer="substring-after(., '|')"/>
+
+  <gt:escapeRule selector="//msg:message/*[@unescape = 'yes']" escape="no"/>
+
+  <its:translateRule selector="//msg:message/@unescaped" translate="yes"/>
+  <gt:escapeRule selector="//msg:message/@unescaped" escape="no"/>
 </its:rules>
 EOF
 
@@ -160,6 +165,12 @@ cat <<\EOF >messages.xml
       but not middle  
     </p>
   </message>
+  <message>
+    <p unescape="yes">This is an unescaped element &lt;&gt;&amp;&quot;</p>
+  </message>
+  <message unescaped="This is an unescaped attribute &lt;&gt;&amp;&quot;">
+    <p></p>
+  </message>
 </messages>
 EOF
 
@@ -226,6 +237,16 @@ msgid ""
 "Leading/trailing  whitespaces are  removed,\n"
 "      but not middle"
 msgstr ""
+
+#. (itstool) path: message/p
+#: messages.xml:59
+msgid "This is an unescaped element <>&\""
+msgstr ""
+
+#. (itstool) path: messages/message@unescaped
+#: messages.xml:61
+msgid "This is an unescaped attribute <>&\""
+msgstr ""
 EOF
 
 : ${DIFF=diff}