Don't write internal quotes during normal use (fixes #30)

This commit is contained in:
Matt Nadareski
2020-09-30 10:07:53 -07:00
parent 2099a82b2b
commit d82a911cd9

View File

@@ -137,6 +137,10 @@ namespace SabreTools.Library.IO
{ {
try try
{ {
// If we're writing quotes, don't write out quote characters internally
if (Quotes)
name = name.Replace("\"", "''");
AutoComplete(Token.StartElement); AutoComplete(Token.StartElement);
PushStack(); PushStack();
stack[top].Name = name; stack[top].Name = name;
@@ -200,6 +204,10 @@ namespace SabreTools.Library.IO
{ {
try try
{ {
// If we're writing quotes, don't write out quote characters internally
if (Quotes)
name = name.Replace("\"", "''");
AutoComplete(Token.StartAttribute); AutoComplete(Token.StartAttribute);
sw.Write(name); sw.Write(name);
sw.Write(" "); sw.Write(" ");
@@ -266,6 +274,14 @@ namespace SabreTools.Library.IO
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
throw new ArgumentException(); throw new ArgumentException();
// If we're writing quotes, don't write out quote characters internally
if ((quoteOverride == null && Quotes)
|| (quoteOverride == true))
{
name = name.Replace("\"", "''");
value = value.Replace("\"", "''");
}
AutoComplete(Token.Standalone); AutoComplete(Token.Standalone);
sw.Write(name); sw.Write(name);
sw.Write(" "); sw.Write(" ");
@@ -315,6 +331,11 @@ namespace SabreTools.Library.IO
if (!string.IsNullOrEmpty(value)) if (!string.IsNullOrEmpty(value))
{ {
AutoComplete(Token.Content); AutoComplete(Token.Content);
// If we're writing quotes, don't write out quote characters internally
if (Quotes)
value = value.Replace("\"", "''");
sw.Write(value); sw.Write(value);
} }
} }