diff options
author | 2022-08-29 17:54:09 +0800 | |
---|---|---|
committer | 2022-08-29 17:08:22 +0000 | |
commit | a1da277369dac12421d730cf1c551275f2072489 (patch) | |
tree | 687d490a595199f636667a04549acb5885f7bd74 | |
parent | 77689d19974b726c33eedd6508fe71e9b977b89b (diff) |
Fix aapt2 dump xmltree not escape text nodes
The text of CDATA in XML document should be escaped before the CDATA
text is printed.
Dump xmltree command use XmlPrinter inheriting from xml:ConstVisitor.
To fix issue, it only needs to modify
XmlPrinter::Visit(const xml::Text).
Bug: 140373430
Test: aapt2 dump xmltree --file res/xml/test.xml app_debug.apk
Change-Id: I4f43120b4fbc2ea7136fb51fdeb24e254b94c60f
-rw-r--r-- | tools/aapt2/Debug.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index dfa229173373..f9e52b491413 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -33,6 +33,7 @@ #include "ValueVisitor.h" #include "android-base/logging.h" #include "android-base/stringprintf.h" +#include "androidfw/ResourceTypes.h" #include "idmap2/Policies.h" #include "text/Printer.h" #include "util/Util.h" @@ -515,7 +516,8 @@ class XmlPrinter : public xml::ConstVisitor { } void Visit(const xml::Text* text) override { - printer_->Println(StringPrintf("T: '%s'", text->text.c_str())); + printer_->Println( + StringPrintf("T: '%s'", android::ResTable::normalizeForOutput(text->text.c_str()).c_str())); } private: |