mirror of
https://github.com/openharmony/third_party_gettext.git
synced 2026-07-18 18:24:28 -04:00
xgettext: Respect ITS escape rule for attributes
* 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.
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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 <>&"</p>
|
||||
</message>
|
||||
<message unescaped="This is an unescaped attribute <>&"">
|
||||
<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}
|
||||
|
||||
Reference in New Issue
Block a user