diff --git a/XmlFormat/IO/XmlFileWriter.cs b/XmlFormat/IO/XmlFileWriter.cs index dc97deb..3ca5c00 100644 --- a/XmlFormat/IO/XmlFileWriter.cs +++ b/XmlFormat/IO/XmlFileWriter.cs @@ -40,7 +40,7 @@ namespace RobloxFiles.XmlFormat foreach (Instance child in inst.GetChildren()) RecordInstances(file, child); - if (inst.XmlReferent == "") + if (inst.XmlReferent.Length < 35) inst.XmlReferent = CreateReferent(); file.Instances.Add(inst.XmlReferent, inst); diff --git a/XmlFormat/PropertyTokens/Tokens/Content.cs b/XmlFormat/PropertyTokens/Tokens/Content.cs index 514bbe8..fad23e3 100644 --- a/XmlFormat/PropertyTokens/Tokens/Content.cs +++ b/XmlFormat/PropertyTokens/Tokens/Content.cs @@ -20,9 +20,16 @@ namespace RobloxFiles.XmlFormat.PropertyTokens if (contentType.StartsWith("binary") || contentType == "hash") { - // Roblox technically doesn't support this anymore, but load it anyway :P - byte[] buffer = Convert.FromBase64String(content); - prop.RawBuffer = buffer; + try + { + // Roblox technically doesn't support this anymore, but load it anyway :P + byte[] buffer = Convert.FromBase64String(content); + prop.RawBuffer = buffer; + } + catch + { + Console.WriteLine("ContentToken: Got illegal base64 string: {0}", content); + } } } @@ -40,8 +47,17 @@ namespace RobloxFiles.XmlFormat.PropertyTokens type = "url"; XmlElement contentType = doc.CreateElement(type); - contentType.InnerText = content; + if (type == "binary") + { + XmlCDataSection cdata = doc.CreateCDataSection(content); + contentType.AppendChild(cdata); + } + else + { + contentType.InnerText = content; + } + node.AppendChild(contentType); } } diff --git a/XmlFormat/XmlRobloxFile.cs b/XmlFormat/XmlRobloxFile.cs index ddf2eba..9581e51 100644 --- a/XmlFormat/XmlRobloxFile.cs +++ b/XmlFormat/XmlRobloxFile.cs @@ -29,7 +29,7 @@ namespace RobloxFiles.XmlFormat string xml = Encoding.UTF8.GetString(buffer); Root.LoadXml(xml); } - catch + catch (Exception e) { throw new Exception("XmlRobloxFile: Could not read provided buffer as XML!"); } @@ -82,6 +82,7 @@ namespace RobloxFiles.XmlFormat { string name = refProp.GetFullName(); Console.WriteLine("XmlRobloxFile: Could not resolve reference for {0}", name); + refProp.Value = null; } } @@ -158,6 +159,7 @@ namespace RobloxFiles.XmlFormat using (BinaryWriter writer = new BinaryWriter(stream)) { byte[] data = Encoding.UTF8.GetBytes(result); + stream.SetLength(0); writer.Write(data); } }