Skip to content

Commit

Permalink
parser: sensible psd exporters don't add an extra null terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Jul 1, 2022
1 parent f409673 commit f12e0ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/psd/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,10 @@ LayerMaskSection* parseLayer(ref File file, ref PSD psd, ulong sectionOffset, ui

// If there's a unicode name we may as well use that here.
import std.utf : toUTF8;
layer.name = utf16Name.toUTF8[0..$-1]; // strip null character as well
layer.name = utf16Name.toUTF8;

// Some PSD exporters throw an extra null in there for good measure, yeet it.
if (layer.name[$-1] == '\0') layer.name.length--;

// skip possible padding bytes
file.skip(length - 4u - characterCountWithoutNull * ushort.sizeof);
Expand Down

0 comments on commit f12e0ad

Please sign in to comment.