Get the new PortableApps.com Platform 10.0: Gorgeous themes, a full portable app store and advanced functionality
Announcing the World's Best Flash Drive: The PortableApps.com Companion | Did you see a malware warning on Friday?

Escape characters for paths in NSIS

nnewton - June 10, 2009 - 1:57am

Is this still an unresolvable issue with the NS installer?

http://portableapps.com/node/4530

I just installed the portable GPG and Enigmail and the path to my gpg.exe is being changed when I exit TB. The path for my TB includes a directory starting with a lowercase n, NSIS seems to turn this into some control character when it saves back to the "extensions.enigmail.agentPath" line in pref.js. Works fine with an uppercase N though.

This only happens with the path to gpg.exe, all the other paths in pref.js are fine.


( categories: )

This finally annoyed me

This finally annoyed me enough that I decided to learn how to use NSIS and fix it myself.

Edit the ThunderbirdPortable.nsi file:

Add StrRep.nsh to the ;(NSIS Plugins) includes section near the top of the file:

!include StrRep.nsh

In the GPGEnvironment section, insert the following immediately before the FileWrite $0 `user_pref("extensions.enigmail.agentPath", "$GPGPATHDIRECTORY\gpg.exe");` line:

;Correct a problem with escape sequences, eg \n or \r in the path
${StrReplace} "$GPGPATHDIRECTORY" "\" "~TmpRepStr~" "$GPGPATHDIRECTORY"
${StrReplace} "$GPGPATHDIRECTORY" "~TmpRepStr~" "\\" "$GPGPATHDIRECTORY"

See here if you want to know why it needs two lines:

http://nsis.sourceforge.net/Talk:StrRep

Recompile with NSIS and run.