kcrawford / dockutil

command line tool for managing dock items
http://patternbuffer.wordpress.com
Apache License 2.0
1.37k stars 131 forks source link

Paths with § in the name crash dockutil and leave a broken com.apple.dock.plist file. #73

Closed magnusviri closed 2 years ago

magnusviri commented 7 years ago

I have applications with § in the name. This is the command I ran. /usr/local/bin/dockutil --no-restart --add "/Applications/StatPlus §.app" "/Users/scholar/Library/Preferences/com.apple.dock.plist"

This is the crash.

Traceback (most recent call last): File "/usr/local/bin/dockutil", line 654, in main() File "/usr/local/bin/dockutil", line 362, in main commitPlist(pl, plist_path, restart_dock) File "/usr/local/bin/dockutil", line 616, in commitPlist writePlist(pl, plist_path) File "/usr/local/bin/dockutil", line 373, in writePlist plistlib.writePlist(pl, plist_path) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 94, in writePlist writer.writeValue(rootObject) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 252, in writeValue self.writeDict(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 281, in writeDict self.writeValue(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 258, in writeValue self.writeArray(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 287, in writeArray self.writeValue(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 252, in writeValue self.writeDict(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 281, in writeDict self.writeValue(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 252, in writeValue self.writeDict(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 281, in writeDict self.writeValue(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 252, in writeValue self.writeDict(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 281, in writeDict self.writeValue(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 239, in writeValue self.simpleElement("string", value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 172, in simpleElement value = _escapeAndEncode(value) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 222, in _escapeAndEncode return text.encode("utf-8") # encode as UTF-8 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 23: ordinal not in range(128)

If I try to run dockutil on that file again, I get this error.

/Users/scholar/Library/Preferences/com.apple.dock.plist: Property List error: Encountered unexpected EOF / JSON error: JSON text did not start with array or object and option to allow fragments not set. failed to convert plist "/Users/scholar/Library/Preferences/com.apple.dock.plist"

kcrawford commented 2 years ago

This issue is resolved in dockutil 3. Thanks for reporting the issue!