Escape the value of the filepath attribute.

* src/abg-writer.cc (write_location): Sanitize the filepath with
	xml::escape_xml_string().
	(write_translation_unit): Likewise.
	(write_corpus_to_native_xml): Likewise.
	* tests/data/test-types-stability/pr19433-custom0: Add a new test file.
	* tests/test-types-stability.cc: Add the test file to the test harness.
	* tests/data/Makefile.am: Add the new test file to the list.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
This commit is contained in:
Ondrej Oprala 2016-01-18 08:51:21 +01:00
parent 64375c64d3
commit c8c7a3b5e7
4 changed files with 6 additions and 4 deletions

View File

@ -592,7 +592,7 @@ write_location(const location& loc, ostream& o)
loc.expand(filepath, line, column);
o << " filepath='" << filepath << "'"
o << " filepath='" << xml::escape_xml_string(filepath) << "'"
<< " line='" << line << "'"
<< " column='" << column << "'";
}
@ -620,7 +620,7 @@ write_location(const decl_base_sptr& decl,
loc.expand(filepath, line, column);
o << " filepath='" << filepath << "'"
o << " filepath='" << xml::escape_xml_string(filepath) << "'"
<< " line='" << line << "'"
<< " column='" << column << "'";
}
@ -1210,7 +1210,7 @@ write_translation_unit(const translation_unit& tu,
o << " address-size='" << static_cast<int>(tu.get_address_size()) << "'";
if (!tu.get_path().empty())
o << " path='" << tu.get_path() << "'";
o << " path='" << xml::escape_xml_string(tu.get_path()) << "'";
if (tu.get_language() != translation_unit::LANG_UNKNOWN)
o << " language='"
@ -3141,7 +3141,7 @@ write_corpus_to_native_xml(const corpus_sptr corpus,
do_indent_to_level(ctxt, indent, 0);
out << "<abi-corpus";
if (!corpus->get_path().empty())
out << " path='" << corpus->get_path() << "'";
out << " path='" << xml::escape_xml_string(corpus->get_path()) << "'";
if (!corpus->get_architecture_name().empty())
out << " architecture='" << corpus->get_architecture_name()<< "'";

View File

@ -318,6 +318,7 @@ test-types-stability/pr19139-DomainNeighborMapInst.o \
test-types-stability/pr19202-libmpi_gpfs.so.5.0 \
test-types-stability/pr19026-libvtkIOSQL-6.1.so.1 \
test-types-stability/pr19138-elf0 \
test-types-stability/pr19433-custom0 \
\
test-diff-filter/test0-v0.cc \
test-diff-filter/test0-v1.cc \

Binary file not shown.

View File

@ -57,6 +57,7 @@ const char* elf_paths[] =
"data/test-types-stability/pr19202-libmpi_gpfs.so.5.0",
"data/test-types-stability/pr19026-libvtkIOSQL-6.1.so.1",
"data/test-types-stability/pr19138-elf0",
"data/test-types-stability/pr19433-custom0",
// The below should always be the last element of array.
0
};