#1092 !finalize swallows parameters containing national characters (WIN1250)

3.0 Alpha Series
closed-out-of-date
nobody
None
1
2016-12-28
2014-03-11
No

After the following line in the nsi file:

!finalize 'p:\signing\dosign.cmd "%1" "CSD Pénzügy Bér gyorsjavítás" "http://www.###.hu" "X"'

the cmd file is called with the following parameters:

1: "setup-ber-2014-Fix-21.exe"
3: "http://www.###.hu"
4: "X"

so the %2 parameter is swallowed.

Changing the line to
!finalize 'p:\signing\dosign.cmd "%1" "CSD Penzugy Ber gyorsjavitas" "http://www.###.hu" "X"'

the output is

1: "setup-ber-2014-Fix-21.exe"
2: "CSD Penzugy Ber gyorsjavitas"
3: "http://www.###.hu"
4: "X"

the cmd file is http://pastebin.com/BMnBRJ1h

Discussion

  • Anders

    Anders - 2014-03-11

    The problem is not with !finalize, it does not eat any parameters.

    During testing I used:

    !verbose 4
    outfile "test.exe"
    requestexecutionlevel user
    showinstdetails show
    !finalize 'test.cmd "%1" "CSD Penzugy Ber gyorsjavitas" "http://www.###.hu" "X"'
    !finalize 'test.cmd "%1" "CSD Pénzügy Bér gyorsjavítás" "http://www.###.hu" "X"'
    !finalize '"%1" "%1" "CSD Pénzügy Bér gyorsjavítás" "http://www.###.hu" "X"'
    section
    detailprint $CMDLINE
    sectionend
    

    and

    @echo off
    echo All=%*
    echo 1=%1
    echo 2=%2
    echo 3=%3
    echo 4=%4
    

    !finalize runs the child process with the correct parameters as you can see: http://i.imgur.com/LQ8QZCH.png This works for both the batch file and when calling itself as a exe.

    The problem is somewhere in the cmd.exe batch handling (You can see that in your output as well since the whole "2: .." part is missing). MakeNSIS calls SetConsoleOutputCP(CP_UTF8) before starting the child process and this seems to make it worse. If I revert to CP_ACP I at least get output but it is broken: http://i.imgur.com/00paiFv.png

    If I force the codepage to CP_OEMCP the output seems to be correct.

    Even with no code change "makensis .\test.nsi > test.txt" seems to work correctly (And "makensis /OCS UTF8SIG .\test.nsi > test.txt" will give you a correct UTF-8 file)

    I don't think we can change the default to CP_OEMCP but we should probably think about adding it as a !finalize parameter...

     
  • Anders

    Anders - 2014-03-11

    Even when the output is broken it seems like executing things in the batch file should work: http://i.imgur.com/0tCdvlG.png

    Does your batch file fail to sign the .exe or is it just the output that is broken?

     
  • Ádám Péter

    Ádám Péter - 2014-03-11

    Thank you for investigating!

    nsi script encoding is WIN1250. Your test shows me the same as you have seen.

    Running with /V4 script yields: Processing script file: "Ber-Hotfix-Exe.nsi" (ACP)

    The cmd file that launches NSIS is: http://pastebin.com/9UR43rTf
    The updater nsi file is: http://pastebin.com/94pknMzW
    The passed nsh file is not used in this kind of update.
    dosign.cmd is now the already included test batch file.
    The installer files are in the p:\Delphi projects\csd_ber_2014\trunk\ins folder.
    The test cmd is in the p:\Signing folder.
    Compiling the solution by starting the batch file yields:
    Finalize command: p:\signing\dosign.cmd "setup-ber-2014-Fix-21.exe" "CSD Pénzügy
    Bér gyorsjavítás" "http://www.adampeter.hu" "X"
    1: "setup-ber-2014-Fix-21.exe"
    3: "http://www.adampeter.hu"
    4: "X"
    5:
    6:
    7:
    8:
    MakeNSIS done - hit enter to close...

    The mode command in a console windows shows that the used codepage is 852. I think the OEM charset conversion should be used when the OS is not US-en, or something like - but it should just mangle the string, not eliminate it.

    Starting from the command line directly with

    "c:\Program Files\NSIS\makensis.exe" /V4 /pause /Duser=user-edit.nsh Ber-Hotfix-Exe.nsi

    yields the same result.

     
  • Anders

    Anders - 2014-03-11

    ..but does p:\signing\dosign.cmd successfully sign the .exe?

     
  • Ádám Péter

    Ádám Péter - 2014-03-11

    No, it fails with:

    Finalize command: p:\signing\dosign.cmd "setup-ber-2014-Fix-21.exe" "CSD Pénzügy Bér gyorsjavítás" "http://www.adampeter.hu" "X"
    p:\Signing\signtool.exe sign /f p:\Signing\csd.pfx /p ** /t http://timestamp.verisign.com/4-Fix-21.exe"
    Error information: "Error: Store IsDiskFile() failed." (-2147024893/0x80070003)
    SignTool Error: An unexpected internal error has occurred.

    MakeNSIS done - hit enter to close...

    , where ** is the correct password, and the output is from an echo command, error message is from the same command the echo printed.

    However, as far as I have found about this error, it is about problem with the pfx file.

     
  • Ádám Péter

    Ádám Péter - 2014-03-11

    I have restored the pfx file from a backup and it works. I don't know why it kills the %2 parameter in the test cmd file and why it mangles the output of the echo command but works. Maybe echo doesn't love what it gets.

    Thank you for your help, and excuse me for giving some unnecessary work.

    Thanks for keeping and enhancing NSIS, !finalize and !GetDllVersion rocks!

     
  • Anders

    Anders - 2014-03-30
    • Priority: 5 --> 1

    !system now changes to CP_OEMCP if it believes that is what stdout is/wants. This should improve the batch file handling...

     
    Last edit: Anders 2014-03-30
  • Anders

    Anders - 2016-12-28
    • status: open --> closed-out-of-date
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks