Search code examples
nsis

NSIS push, pop and URLEncode


I'm trying to encode with URLEncode a strings in NSIS. I'm using a NSIS plugin called URLEncode. The problem is that I try encode 2 vars, but the first encoded var lost the value after I encoded the second var.

Push "${AFF_NAME}"
Call URLEncode
Pop $3
;at this point the messagebox show the result good.
MessageBox MB_OK $3

ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "ProductName"
Push $0
Call URLEncode
Pop $0
;now after second var encoded the result of first var $3 lost the value
MessageBox MB_OK $3

Please Help I'm very new using NSIS and I dont know how do it good. I searching info but without success.

Very thanks !


Solution

  • I'm not aware of a URLEncode plug-in but there is a helper function on the NSIS wiki called URLEncode and it fails to preserve the registers.

    You can fix it by modifying the start and end of the function so it looks like this:

    ; Start
    Function URLEncode
        System::Store S ; Save registers
        Pop $0 ;param
    
        ...
    
    Done:
        Push $9
        System::Store L ; Restore registers
    FunctionEnd
    ; End