[mapguide-commits] r7063 - trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Oct 1 11:04:50 PDT 2012
Author: jng
Date: 2012-10-01 11:04:50 -0700 (Mon, 01 Oct 2012)
New Revision: 7063
Modified:
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs
Log:
#2136: Fix FDO class name encoding/decoding. Port back 4.0.x implementation, just to play safe with Mono.
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs 2012-10-01 17:58:35 UTC (rev 7062)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs 2012-10-01 18:04:50 UTC (rev 7063)
@@ -635,8 +635,10 @@
for (int i = 0; i < tokens.Length; i++)
{
string token = tokens[i];
+ bool bMatchedToken = false;
if (TokenRegex.Match(token, 0).Success)
{
+ bMatchedToken = true;
// the token happens to match the encoding pattern. We want to avoid
// decoding this sub-string on decode. This is done by encoding the leading
// dash.
@@ -647,6 +649,7 @@
}
else if (TokenRegex2.Match(token, 0).Success && i == 0)
{
+ bMatchedToken = true;
// the token happens to match the encoding pattern for the 1st character.
// We want to avoid decoding this sub-string on decode.
// This is done by prepending a dummy encoding for character 0. This character is
@@ -665,7 +668,7 @@
outName.Append("-");
}
}
- outName.Append(ReplaceBadChars(token));
+ outName.Append(bMatchedToken ? token : ReplaceBadChars(token));
}
@@ -704,7 +707,7 @@
bool bFirstChar = true;
foreach (char c in token)
{
- if (XmlConvert.IsNCNameChar(c))
+ if (Char.IsDigit(c) || IsValidXmlChar(c))
sb.Append(c);
else
sb.AppendFormat("{0}x{1:X}-", bFirstChar ? "_" : "-", Convert.ToInt32(c));
@@ -714,6 +717,19 @@
return sb.ToString();
}
+ private static bool IsValidXmlChar(char c)
+ {
+ try
+ {
+ XmlConvert.VerifyNCName(c + "");
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
/// <summary>
/// Converts FDO encoded characters into their original character.
/// </summary>
More information about the mapguide-commits
mailing list