TooTallNate / plist.js

Mac OS X Plist parser/builder for Node.js and browsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

base64 detection

mreinstein opened this issue · comments

@pimetrai can you please elaborate on your base64 detection logic? I'm refering to this code block:

if (base64Matcher.test(tok.replace(/\s/g,'')) && (tok.length>125)) {
    child.ele('data').raw(tok);
} else {
     child.ele('string').raw(tok);
}

I'm assuming that <string> elements can only be 125 characters or less? Also, shouldn't this be an OR condition rather than an AND? I'd assume if either of these conditions passed we'd want to encode as data.

The DTD doesn't mention anything about length requirements.

http://www.apple.com/DTDs/PropertyList-1.0.dtd

Correct. I dont think the length check needs to be in there but it's a specific number so I am hoping to get the authors feedback on why it's there. Would prefer to understand why the check was created rather than just deleting it. If I don't hear anything from him by tomorrow I'll just nuke it from LEO I guess. :/

fixed. node-plist@0.4.1 fixes this problem. Added base64encode validation on parse, flipped condition on data vs string (good catch @filmaj ), and added unit tests.