Brought spec up to date, improvements to stability

This commit is contained in:
CloneTrooper1019
2020-07-12 20:19:30 -05:00
parent 7359b6efb7
commit 57fd3f8a25
29 changed files with 551 additions and 245 deletions

View File

@ -1,4 +1,5 @@
using System.Xml;
using System.Text;
using System.Xml;
using RobloxFiles.DataTypes;
namespace RobloxFiles.XmlFormat.PropertyTokens
@ -10,7 +11,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
public bool ReadProperty(Property prop, XmlNode token)
{
ProtectedString contents = token.InnerText;
prop.Type = PropertyType.String;
prop.Type = PropertyType.ProtectedString;
prop.Value = contents;
return true;
@ -18,16 +19,26 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
string value = prop.CastValue<ProtectedString>();
ProtectedString value = prop.CastValue<ProtectedString>();
if (value.Contains("\r") || value.Contains("\n"))
if (value.IsCompiled)
{
XmlCDataSection cdata = doc.CreateCDataSection(value);
node.AppendChild(cdata);
var binary = XmlPropertyTokens.GetHandler<BinaryStringToken>();
binary.WriteProperty(prop, doc, node);
}
else
{
node.InnerText = value;
string contents = Encoding.UTF8.GetString(value.RawBuffer);
if (contents.Contains("\r") || contents.Contains("\n"))
{
XmlCDataSection cdata = doc.CreateCDataSection(contents);
node.AppendChild(cdata);
}
else
{
node.InnerText = contents;
}
}
}
}

View File

@ -9,17 +9,25 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
public bool ReadProperty(Property prop, XmlNode token)
{
string md5 = token.InnerText;
string key = token.InnerText;
prop.Type = PropertyType.SharedString;
prop.Value = new SharedString(md5);
prop.Value = new SharedString(key);
return true;
}
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
SharedString value = prop.CastValue<SharedString>();
node.InnerText = value.MD5_Key;
var value = prop.CastValue<SharedString>();
string key = value.Key;
if (value.ComputedKey == null)
{
var newShared = SharedString.FromBuffer(value.SharedValue);
key = newShared.ComputedKey;
}
node.InnerText = key;
}
}
}