From a1da277369dac12421d730cf1c551275f2072489 Mon Sep 17 00:00:00 2001 From: felkachang Date: Mon, 29 Aug 2022 17:54:09 +0800 Subject: 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 --- tools/aapt2/Debug.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/aapt2/Debug.cpp') 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: -- cgit v1.2.3-59-g8ed1b