You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2020/05/26 17:34:43 UTC

[royale-asjs] branch develop updated: RoyaleUnit: CIListener escapes attributes with the correct type to fix issue where quotes were not escaped properly

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 8378f7f  RoyaleUnit: CIListener escapes attributes with the correct type to fix issue where quotes were not escaped properly
8378f7f is described below

commit 8378f7f728ca619478f6cdf0f2ae04700de2e94f
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 26 10:34:32 2020 -0700

    RoyaleUnit: CIListener escapes attributes with the correct type to fix issue where quotes were not escaped properly
---
 .../org/apache/royale/test/listeners/CIListener.as | 31 +++++++++++-----------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/CIListener.as b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/CIListener.as
index a21d4c9..127f22f 100644
--- a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/CIListener.as
+++ b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/listeners/CIListener.as
@@ -208,8 +208,8 @@ package org.apache.royale.test.listeners
 			//whitespace in the XML to be formatted in an exact way
 			var xml:String =
 				"<testcase" +
-					" classname=\"" + escapeXML(descriptor.suite) + "\"" +
-					" name=\"" + escapeXML(descriptor.method) + "\"" +
+					" classname=\"" + escapeXMLAttribute(descriptor.suite) + "\"" +
+					" name=\"" + escapeXMLAttribute(descriptor.method) + "\"" +
 					" time=\"" + lastTestTime + "\"" +
 					" status=\"" + STATUS_SUCCESS + "\"" +
 					" />"
@@ -220,7 +220,7 @@ package org.apache.royale.test.listeners
 		/**
 		 * @private
 		 */
-		protected function escapeXML(value:String):String
+		protected function escapeXMLAttribute(value:String):String
 		{
 			if(value == null)
 			{
@@ -234,8 +234,9 @@ package org.apache.royale.test.listeners
 			COMPILE::JS
 			{
 				var serializer:XMLSerializer = new XMLSerializer()
-				var textNode:Text = document.createTextNode(value);
-				return serializer.serializeToString(textNode);
+				var attr:Attr = document.createAttribute("attr");
+				attr.value = value;
+				return serializer.serializeToString(attr);
 			}
 		}
 		
@@ -250,8 +251,8 @@ package org.apache.royale.test.listeners
 			//whitespace in the XML to be formatted in an exact way
 			var xml:String =
 				"<testcase" +
-					" classname=\"" + escapeXML(descriptor.suite) + "\"" +
-					" name=\"" + escapeXML(descriptor.method) + "\"" +
+					" classname=\"" + escapeXMLAttribute(descriptor.suite) + "\"" +
+					" name=\"" + escapeXMLAttribute(descriptor.method) + "\"" +
 					" time=\"0\"" +
 					" status=\"" + STATUS_IGNORE + "\"" +
 					">" +
@@ -276,14 +277,14 @@ package org.apache.royale.test.listeners
 				//whitespace in the XML to be formatted in an exact way
 				xml =
 					"<testcase" +
-						" classname=\"" + escapeXML(descriptor.suite) + "\"" +
-						" name=\"" + escapeXML(descriptor.method) + "\"" +
+						" classname=\"" + escapeXMLAttribute(descriptor.suite) + "\"" +
+						" name=\"" + escapeXMLAttribute(descriptor.method) + "\"" +
 						" time=\"" + lastTestTime + "\"" +
 						" status=\"" + STATUS_FAILURE + "\"" +
 						">" +
 						"<failure" +
-							" message=\"" + escapeXML(failure.message) + "\"" +
-							" type=\"" + escapeXML(failure.description) + "\"" +
+							" message=\"" + escapeXMLAttribute(failure.message) + "\"" +
+							" type=\"" + escapeXMLAttribute(failure.description) + "\"" +
 							">" +
 							"<![CDATA[" + failure.stackTrace + "]]>" +
 						"</failure>" +
@@ -295,14 +296,14 @@ package org.apache.royale.test.listeners
 				//whitespace in the XML to be formatted in an exact way
 				xml =
 					"<testcase" +
-						" classname=\"" + escapeXML(descriptor.suite) + "\"" +
-						" name=\"" + escapeXML(descriptor.method) + "\"" +
+						" classname=\"" + escapeXMLAttribute(descriptor.suite) + "\"" +
+						" name=\"" + escapeXMLAttribute(descriptor.method) + "\"" +
 						" time=\"" + lastTestTime + "\"" +
 						" status=\"" + STATUS_ERROR + "\"" +
 						">" +
 						"<error" +
-							" message=\"" + escapeXML(failure.message) + "\"" +
-							" type=\"" + escapeXML(failure.description) + "\"" +
+							" message=\"" + escapeXMLAttribute(failure.message) + "\"" +
+							" type=\"" + escapeXMLAttribute(failure.description) + "\"" +
 							">" +
 							"<![CDATA[" + failure.stackTrace + "]]>" +
 						"</error>" +