* Utilities.cs (UnescapeFromXml): New. From md.
authorAnkit Jain <radical@corewars.org>
Wed, 26 Aug 2009 01:55:56 +0000 (01:55 -0000)
committerAnkit Jain <radical@corewars.org>
Wed, 26 Aug 2009 01:55:56 +0000 (01:55 -0000)
* BuildProperty.cs (.ctor): Unescape xml codes from the InnerXml
of the property element.

svn path=/trunk/mcs/; revision=140683

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildProperty.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Utilities.cs

index 841d3aab355140864d542f47075fbbd1cc4fe816..ff75d989e34cb84a6d2b8110596e4f6254a3d3ec 100644 (file)
@@ -76,7 +76,7 @@ namespace Microsoft.Build.BuildEngine {
                        this.propertyType = PropertyType.Normal;
                        this.parentProject = parentProject;
                        this.name = propertyElement.Name;
-                       this.value = propertyElement.InnerXml;
+                       this.value = Utilities.UnescapeFromXml (propertyElement.InnerXml);
                        this.isImported = false;
                }
 
index ca6ba78954863485464312b3a722b7a2d43d9925..e9838f26be582f90495e11d868aafad476f68c4e 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-26  Ankit Jain  <jankit@novell.com>
+
+       * Utilities.cs (UnescapeFromXml): New. From md.
+       * BuildProperty.cs (.ctor): Unescape xml codes from the InnerXml
+       of the property element.
+
 2009-08-26  Ankit Jain  <jankit@novell.com>
 
        * BuildProperty.cs (ConvertToString): New.
index 579785db639fee097428f17babd5b7c9607352c5..7fa30bc675bf4e5b575476b2dd40f3f221ba5bcc 100644 (file)
@@ -4,6 +4,7 @@
 // Author:
 //   Marek Sieradzki (marek.sieradzki@gmail.com)
 //   Lluis Sanchez Gual <lluis@novell.com>
+//   Michael Hutchinson <mhutchinson@novell.com>
 //
 // (C) 2005 Marek Sieradzki
 // Copyright (c) 2008 Novell, Inc (http://www.novell.com)
@@ -81,6 +82,43 @@ namespace Microsoft.Build.BuildEngine {
                        return sb.ToString ();
                }
 
+               internal static string UnescapeFromXml (string text)
+               {
+                       StringBuilder sb = new StringBuilder ();
+                       for (int i = 0; i < text.Length; i++) {
+                               char c1 = text[i];
+                               if (c1 == '&') {
+                                       int end = text.IndexOf (';', i);
+                                       if (end == -1)
+                                               throw new FormatException ("Unterminated XML entity.");
+                                       string entity = text.Substring (i+1, end - i - 1);
+                                       switch (entity) {
+                                       case "lt":
+                                               sb.Append ('<');
+                                               break;
+                                       case "gt":
+                                               sb.Append ('>');
+                                               break;
+                                       case "amp":
+                                               sb.Append ('&');
+                                               break;
+                                       case "apos":
+                                               sb.Append ('\'');
+                                               break;
+                                       case "quot":
+                                               sb.Append ('"');
+                                               break;
+                                       default:
+                                               throw new FormatException ("Unrecogised XML entity '&" + entity + ";'.");
+                                       }
+                                       i = end;
+                               } else
+                                       sb.Append (c1);
+                       }
+                       return sb.ToString ();
+               }
+
+
                internal static string FromMSBuildPath (string relPath)
                {
                        if (relPath == null || relPath.Length == 0)