sf bug 1519: unescaped entities in XML logs (from make errors) fix
authorRichard Taylor <richard.i.taylor@nokia.com>
Thu, 28 Jan 2010 16:06:25 +0000
branchfix
changeset 176 b601167a8189
parent 175 eff54c65de8b
child 177 a363840a27e3
sf bug 1519: unescaped entities in XML logs (from make errors)
sbsv2/raptor/python/plugins/filter_broken.py
sbsv2/raptor/python/raptor_make.py
sbsv2/raptor/test/smoke_suite/make_engine_errors.py
sbsv2/raptor/test/smoke_suite/test_resources/make_engine_errors/bld.inf
sbsv2/raptor/test/smoke_suite/test_resources/make_engine_errors/with_make_errors.flm
sbsv2/raptor/test/smoke_suite/test_resources/make_engine_errors/with_make_errors.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/python/plugins/filter_broken.py	Thu Jan 28 16:06:25 2010 +0000
@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+# Example of a Filter class using the SAX parser base class
+#
+
+import filter_interface
+
+class FilterBroken(filter_interface.FilterSAX):
+	
+	def startDocument(self):
+		self.first = True
+		
+	def startElement(self, name, attributes):
+		pass
+	
+	def characters(self, char):
+		pass
+		
+	def endElement(self, name):
+		pass
+	
+	def endDocument(self):
+		pass
+	
+	def error(self, exception):
+		pass
+		
+	def fatalError(self, exception):
+		if self.first:
+			print "fatal error:", str(exception)
+			self.first = False
+		
+	def warning(self, exception):
+		pass
+	
+# the end
--- a/sbsv2/raptor/python/raptor_make.py	Tue Jan 26 14:25:28 2010 +0000
+++ b/sbsv2/raptor/python/raptor_make.py	Thu Jan 28 16:06:25 2010 +0000
@@ -497,12 +497,22 @@
 						universal_newlines=True, env=makeenv)
 				stream = p.stdout
 
-
+				inRecipe = False
 				line = " "
 				while line:
 					line = stream.readline()
-					self.raptor.out.write(line)
-
+					
+					if line.startswith("<recipe"):
+						inRecipe = True
+					elif line.startswith("</recipe"):
+						inRecipe = False
+					
+					# unless we are inside a "recipe", any line not starting
+					# with "<" is free text that must be escaped.
+					if inRecipe or line.startswith("<"):
+						self.raptor.out.write(line)
+					else:
+						self.raptor.out.write(escape(line))
 
 				# should be done now
 				returncode = p.wait()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/test/smoke_suite/make_engine_errors.py	Thu Jan 28 16:06:25 2010 +0000
@@ -0,0 +1,54 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+from raptor_tests import SmokeTest
+
+def run():
+	t = SmokeTest()
+	t.id = "113"
+	t.name = "make_engine_errors"
+	t.description = "Errors reported by gmake and emake should be escaped to ensure that the logs are valid XML"
+	
+	t.mustmatch_singleline = ["Circular b &lt;- a dependency",
+							  "non_existent_&amp;_needs_escaping.txt"]
+	
+	t.mustnotmatch_singleline = ["Circular b <- a dependency",
+							     "non_existent_&_needs_escaping.txt"]
+	
+	t.usebash = True
+	t.errors = 1
+	t.returncode = 1
+	base_command = "sbs -b smoke_suite/test_resources/make_engine_errors/bld.inf -f-"
+	
+	t.id = "113a"
+	t.name = "gmake_engine_errors"
+	t.command = base_command + " -e make"
+	t.run()
+
+	t.id = "113b"
+	t.name = "emake_engine_errors"
+	t.command = base_command + " -e emake"
+	t.run()
+	
+	t.id = "113c"
+	t.name = "emake_engine_errors_with_merged_streams"
+	t.command = base_command + " -e emake --mo=--emake-mergestreams=1"
+	t.run()
+		
+	t.id = "113"
+	t.name = "make_engine_errors"
+	t.print_result()
+	return t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/test/smoke_suite/test_resources/make_engine_errors/bld.inf	Thu Jan 28 16:06:25 2010 +0000
@@ -0,0 +1,9 @@
+
+PRJ_EXPORTS
+with_make_errors.flm /epoc32/tools/makefile_templates/tools/with_make_errors.flm
+with_make_errors.xml /epoc32/tools/makefile_templates/tools/with_make_errors.xml
+
+PRJ_EXTENSIONS
+start extension tools/with_make_errors
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/test/smoke_suite/test_resources/make_engine_errors/with_make_errors.flm	Thu Jan 28 16:06:25 2010 +0000
@@ -0,0 +1,10 @@
+
+ALL:: a b c
+
+a: b
+b: a
+
+c: non_existent_&_needs_escaping.txt
+
+$(call raptor_phony_recipe,name,ALL,,echo "this FLM is rubbish")
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/test/smoke_suite/test_resources/make_engine_errors/with_make_errors.xml	Thu Jan 28 16:06:25 2010 +0000
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?> 
+<build xmlns="http://symbian.com/xml/build" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symbian.com/xml/build build/2_0.xsd"> 
+
+<interface name="tools.with_make_errors" flm="with_make_errors.flm">
+</interface>
+
+</build>