throw new ArgumentException (Locale.GetText ("Invalid XML attribute value") + ": " + value);
_name = name;
- _value = value;
+ _value = SecurityElement.Unescape (value);
}
public string Name {
Locale.GetText ("Invalid XML string")
+ ": " + value);
}
- text = value;
+ text = Unescape (value);
}
}
return sb.ToString ();
}
+ private static string Unescape (string str)
+ {
+ StringBuilder sb;
+
+ if (str == null)
+ return null;
+
+ sb = new StringBuilder (str);
+ sb.Replace ("<", "<");
+ sb.Replace (">", ">");
+ sb.Replace ("&", "&");
+ sb.Replace (""", "\"");
+ sb.Replace ("'", "'");
+ return sb.ToString ();
+ }
+
#if NET_2_0
public
#else
return value != null && value.IndexOfAny (invalid_attr_value_chars) == -1;
}
- public static bool IsValidTag (string value)
+ public static bool IsValidTag (string tag)
{
- return value != null && value.IndexOfAny (invalid_tag_chars) == -1;
+ return tag != null && tag.IndexOfAny (invalid_tag_chars) == -1;
}
- public static bool IsValidText (string value)
+ public static bool IsValidText (string text)
{
- return value != null && value.IndexOfAny (invalid_text_chars) == -1;
+ return text != null && text.IndexOfAny (invalid_text_chars) == -1;
}
public SecurityElement SearchForChildByTag (string tag)
#endif
s.Append (sa.Name)
.Append ("=\"")
- .Append (sa.Value)
+ .Append (Escape (sa.Value))
.Append ("\"");
if (i != attributes.Count - 1)
s.Append (Environment.NewLine);
(children == null || children.Count == 0))
s.Append ("/>").Append (Environment.NewLine);
else {
- s.Append (">").Append (text);
+ s.Append (">").Append (Escape (text));
if (children != null) {
s.Append (Environment.NewLine);
foreach (SecurityElement child in children) {