Bug 17 - MSBuild serializer doesn't handle XML escaping
Summary: MSBuild serializer doesn't handle XML escaping
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: 2.6 Beta 1
Hardware: Other Mac OS
: Normal major
Target Milestone: ---
Assignee: Lluis Sanchez
URL:
: 13980 14121 ()
Depends on:
Blocks:
 
Reported: 2011-07-18 15:27 UTC by Warren Moxley
Modified: 2013-10-16 13:08 UTC (History)
9 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Warren Moxley 2011-07-18 15:27:22 UTC
When you try to save a project after you have selected an iPhone Bundle Signing Identity that has a "&" ampersand character in it, you get an error saving.

"Save failed.  a name did not start with a legal character 32() Line 1, position 33."

I have verified it is definitely the & causing the issue, I suspect it is because the & needs to be escaped to & for the xml serializer to work with it correctly.  

Thanks
Warren
Comment 1 Mikayla Hutchinson [MSFT] 2011-07-21 19:26:50 UTC
Moving to MD core, this is a problem with the project serializer.
Comment 2 Mike Krüger 2011-08-23 04:19:14 UTC
fixed.

@lluis: I'm not sure if the fix fixes all. I assume it fixes only this special bug and it occurs in other situations as well & maybe I fixed it at the wrong location.
Can you take a look at:  

https://github.com/mono/monodevelop/commit/21bfd84dcb24cce96bb03a7b22760167b49f9f6f
Comment 3 Warren Moxley 2011-08-29 16:39:27 UTC
This looks like it should fix it.  Out of curiosity, why wouldn't you use one of the Escape or Unescape methods already exposed within the .net framework?  Besides that, looks good.  What build will this make it into?
Comment 4 Mikayla Hutchinson [MSFT] 2011-08-29 18:27:41 UTC
@mike: Yeah, it's not the right level, and those methods don't handle full XML escaping. We should be using the XML DOM's built-in escaping instead of using InnerXml (so that we have 100% correct escaping), and we can only do that a level down. I think MSBuildProperty.Value should be the text value (InnerText). We could expose MSBuildProperty.XmlValue or ChildNodes if anything really needs to read/write XML verbatim, but I don't think MSBuild properties can have XML content, so it's probably not necessary. It looks like this problem applies to item metadata as well. But as you say, we need Lluis' input.

Warren: I don't think .NET exposes a method to escape/unescape XML. it's only something that happens transparently within XmlReader/XmlWriter.
Comment 5 Warren Moxley 2011-08-29 22:01:43 UTC
If you look where my bug is happening though, its the value inside the xml element that's causing it.  Specifically an &.  The HtmlEncode and HtmlDecode methods (System.Web?) should work perfectly for that when setting and reading the node into the object to be serialized/deserialized when writing the config to disk.
Comment 6 Mikayla Hutchinson [MSFT] 2011-08-30 06:35:23 UTC
We can't just encode items however we want. We need to do it the same way that other MSBuild tools do.
Comment 7 George 2013-08-12 10:18:47 UTC
This bug appears to be happening again in the latest version of Xamarin Studio 4.0.12 (build 3), stable release. With respect to iOS Bundle signing, my "identity" field contains the name of one of my Enterprise customers whose name happens to contain an ampersand. Now when I try to save any changes to my project, I get the dreaded "Save failed. a name did not start with a legal character 32 () Line 1, position 38" error.

This was not happening in recent previous versions of Xamarin Studio.
Comment 8 Mikayla Hutchinson [MSFT] 2013-08-14 17:56:30 UTC
*** Bug 13980 has been marked as a duplicate of this bug. ***
Comment 9 Mikayla Hutchinson [MSFT] 2013-08-14 17:57:27 UTC
This regression seem to have been introduced by https://github.com/mono/monodevelop/commit/a539f96337b4a2b1d98404745c4f96a88a4e5473#L1R1796
Comment 10 Jonathan Shore 2013-08-14 18:01:41 UTC
The fix pointed to is a month old.  Would the "alpha" channel (where I am using 4.1.9 build 6 be that old?  Or is this still a present issue?
Comment 11 Jonathan Shore 2013-08-14 18:02:17 UTC
(ah I see, you indicate is a regression, nevetrmind)
Comment 12 Mikayla Hutchinson [MSFT] 2013-08-14 20:30:29 UTC
Should be fixed by https://github.com/mono/monodevelop/commit/0865add6ff453c936245d17cda31e2a2add2b644
Comment 13 Eric Maurer 2013-08-26 13:17:29 UTC
Is this fix included in any of the current Xamarin Studio builds?  I'm trying to deploy to the app store but can't select my provisioning profile because my team name has a & in it.  Are there any work-arounds for this?
Thanks,
Comment 14 Mikayla Hutchinson [MSFT] 2013-08-26 13:20:20 UTC
No, it's not. It should be in the next release. Only workaround I know would be using Xamarin Studio 4.0.10, sorry!
Comment 15 Eric Maurer 2013-08-26 13:23:18 UTC
How do I revert my version from 4.0.12 to 4.0.10?  Any idea when the next release will be?
Comment 16 Mikayla Hutchinson [MSFT] 2013-08-26 14:41:30 UTC
You can download it here: http://download.xamarin.com/studio/Mac/XamarinStudio-4.0.10-7.dmg

No ETA on the next release, sorry.
Comment 17 Mikayla Hutchinson [MSFT] 2013-09-03 14:55:25 UTC
*** Bug 14121 has been marked as a duplicate of this bug. ***
Comment 18 Marcello Rutter 2013-09-25 08:51:54 UTC
Hi guys.
Please, can you fix this even in version 4.0.12-3?
Thank you very much.
Comment 19 Marcello Rutter 2013-10-16 04:03:28 UTC
I follow up with my previous request just to confirm that this issue has been resolved with Xamarin Studio 4.0.13. Thank you.
Comment 20 Mikayla Hutchinson [MSFT] 2013-10-16 13:08:59 UTC
Thanks for the confirmation!