Skip to content

Commit

Permalink
add basic support for utf-8 openstep plists
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-sz committed Jan 10, 2024
1 parent 4ac87b0 commit f34730a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/common/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// So we just hardcode the correct value.
export const EPOCH = 978307200000;
export const HEADER_BINARY = 'bplist00';
export const HEADER_OPENSTEP_UTF8 = '// !$*UTF8*$!';

export enum PlistFormat {
BINARY,
Expand Down
12 changes: 10 additions & 2 deletions packages/parse/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Value, PlistFormat, HEADER_BINARY } from '@plist/common';
import {
Value,
PlistFormat,
HEADER_BINARY,
HEADER_OPENSTEP_UTF8,
} from '@plist/common';
import { parse as parseBinary } from '@plist/binary.parse';
import { parse as parseXML } from '@plist/xml.parse';
import { parse as parseOpenstep } from '@plist/openstep.parse';
Expand All @@ -17,7 +22,10 @@ export const detectFormat = (input: string | ArrayBuffer): PlistFormat => {
return PlistFormat.XML;
}

if (IS_ASCII.test(trim)) {
if (
input.trimStart().startsWith(HEADER_OPENSTEP_UTF8) ||
IS_ASCII.test(trim)
) {
return PlistFormat.OPENSTEP;
}

Expand Down

0 comments on commit f34730a

Please sign in to comment.