I’m using this plist gem to generate a plist file, which my Rails application will output to user if the request is http://myrailsapp/something.plist
the code responsible for this is pretty simple. (controller)
if @package.present?
format.html
format.plist { render :text => @package.to_plist }
view it im Vim, gives
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>uninstall_script</key>
<string>#!/bin/sh^M
^M
echo "Test"^M
^M
exit 0^M
</string>
<key>uninstallable</key>
<true/>
<key>version</key>
<string>4.7</string>
</dict>
</plist>
On every string line end with a ^M
when I try to debugger this in rails console, it outputs just fine
<key>uninstall_script</key>\n\t<string>#!/bin/sh\r\n\t\r\n\techo "Test"\r\n\t\r\n\texit 0\r\n\t</string>\n\t
No ^M to be find. So any suggestions on where I should look for this issues ?
When the plist that has ^M at the end of the line, another program that reply on this plist doesn’t read it properly. And when I try to remove the ^M manually it works just fine.
Thanks to mu is too short
pointing out that
\ris actually the cause of^M. In that case, I’ve just fixed this bug !!Pretty simple fix just add the following inline to over write the
to_plistmethodAnd that just did the job I wanted