-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Some Safari extensions have quotation marks in their names, and this causes KnockKnock to generate malformed JSON in its output.
Parallels Desktop for Mac includes one such Safari extension. It is called: "Open In" button for Internet Explorer. In fact you can't remove this extension without uninstalling Parallels Desktop entirely. Here's a snippet of /Applications/Parallels Desktop.app/Contents/PlugIns/com.parallels.desktop.console.OpenInIE.appex/Contents/Info.plist
<key>CFBundleDisplayName</key>
<string>"Open In" button for Internet Explorer</string>
<key>CFBundleExecutable</key>
<string>com.parallels.desktop.console.OpenInIE</string>
<key>CFBundleGetInfoString</key>
<string>17.1.2, Copyright 2022 Parallels International GmbH</string>
<key>CFBundleIdentifier</key>
<string>com.parallels.desktop.console.OpenInIE</string>When this extension is present, the following malformed JSON snippet is emitted by KnockKnock:
{"name": ""Open In" button for Internet Explorer", "path": "/Applications/Parallels Desktop.app/Contents/PlugIns/com.parallels.desktop.console.OpenInIE.appex", "identifier": "8AA15FB3-EC66-41B6-9146-EBE12092C87B", "details": "Opens a web page in Internet Explorer inside Windows virtual machine powered by Parallels.", "browser": "/Applications/Safari.app"}...rather than what you'd expect:
{"name": "\"Open In\" button for Internet Explorer", "path": "/Applications/Parallels Desktop.app/Contents/PlugIns/com.parallels.desktop.console.OpenInIE.appex", "identifier": "8AA15FB3-EC66-41B6-9146-EBE12092C87B", "details": "Opens a web page in Internet Explorer inside Windows virtual machine powered by Parallels.", "browser": "/Applications/Safari.app"}With the malformed json the internal prettifier fails to parse its input, which may be what is happening in issue #12.
I believe the problem is here, where these value arguments are interpolated into the string unescaped:
KnockKnock/Results/Extension.m
Line 57 in 7fb16ac
| json = [NSString stringWithFormat:@"\"name\": \"%@\", \"path\": \"%@\", \"identifier\": \"%@\", \"details\": \"%@\", \"browser\": \"%@\"", self.name, self.path, self.identifier, escapedDetails, self.browser]; |
Would you be interested in a PR that implements the NSCoding protocol on these classes? That would simplify the code and avoid the finicky manual JSON construction. Implementing NSCoding would basically make it possible to save and open past scans (or other people's scans) via NSKeyedArchiver... which might be nice.