Skip to content

Commit dbfdbbf

Browse files
committed
Fix CFB stream name handling
1 parent 21dc72b commit dbfdbbf

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

SabreTools.Serialization/Deserializers/CFB.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public static DirectoryEntry ParseDirectoryEntry(Stream data)
244244
var obj = new DirectoryEntry();
245245

246246
byte[] name = data.ReadBytes(64);
247-
obj.Name = Encoding.Unicode.GetString(name).DecodeStreamName();
247+
obj.Name = Encoding.Unicode.GetString(name).DecodeStreamName()?.TrimEnd('\0');
248248
obj.NameLength = data.ReadUInt16LittleEndian();
249249
obj.ObjectType = (ObjectType)data.ReadByteValue();
250250
obj.ColorFlag = (ColorFlag)data.ReadByteValue();

SabreTools.Serialization/Extensions.CFB.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static partial class Extensions
5757
}
5858

5959
output[q] = 0;
60-
return Encoding.ASCII.GetString(output);
60+
return Encoding.UTF8.GetString(output);
6161
}
6262

6363
/// <summary>

SabreTools.Serialization/Printers/CFB.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ private static void Print(StringBuilder builder, DirectoryEntry[]? entries)
103103

104104
builder.AppendLine($" Directory Entry {i}");
105105
builder.AppendLine(entry.Name?.TrimEnd('\0'), " Name");
106+
if (entry.Name != null)
107+
builder.AppendLine(Encoding.UTF8.GetBytes(entry.Name), " Name (bytes)");
106108
builder.AppendLine(entry.NameLength, " Name length");
107109
builder.AppendLine($" Object type: {entry.ObjectType} (0x{entry.ObjectType:X})");
108110
builder.AppendLine($" Color flag: {entry.ColorFlag} (0x{entry.ColorFlag:X})");

0 commit comments

Comments
 (0)