TclGPG  Check-in [0e03edca40]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In addition to encoding set translation to binary if the message-to-be-encipher encoding is set to binary. This closes ticket [e3b54f438c].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0e03edca40f0283ba783e54a214238923c3e21bf
User & Date: sgolovan 2016-04-26 11:16:03
Original Comment: In addition to encoding set translation to binary if the message-to-be-encipher encoding is set to binary. This closes ticket [e3b54f438c]. 2016-01-13 Sergei Golovan <sgolovan@nes.ru> * tclgpg.test: Fixed unsetting GPG_AGENT_INFO. * tclgpg.tcl: Don't treat warnings which gpg sends to the standard error as errors. 2016-01-01 Sergei Golovan <sgolovan@nes.ru> * tclgpg.tcl: Fixed parsing the gpg status output during keys import if there are expired keys in the keyring. Also, added a few code
Context
2016-04-26
12:45
Fixed copyright years. check-in: 7d3683aa69 user: sgolovan tags: trunk
11:16
In addition to encoding set translation to binary if the message-to-be-encipher encoding is set to binary. This closes ticket [e3b54f438c]. check-in: 0e03edca40 user: sgolovan tags: trunk
11:10
Added a test for encrypting binary message intended to catch new line translation issue. Test fails only on Windows. check-in: dcf97702ed user: sgolovan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

1
2
3
4




5
6
7
8
9
10
11
2016-04-26  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.test: Added a test for encrypting binary message intended
	  to catch new line translation issue. Test fails only on Windows.





2016-01-13  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.test: Fixed unsetting GPG_AGENT_INFO.

	* tclgpg.tcl: Don't treat warnings which gpg sends to the standard
	  error as errors.




>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2016-04-26  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.test: Added a test for encrypting binary message intended
	  to catch new line translation issue. Test fails only on Windows.

	* tclgpg.tcl: In addition to encoding set translation to binary if
	  the message-to-be-encipher encoding is set to binary. This closes
	  ticket [e3b54f438c].

2016-01-13  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.test: Fixed unsetting GPG_AGENT_INFO.

	* tclgpg.tcl: Don't treat warnings which gpg sends to the standard
	  error as errors.

Changes to tclgpg.tcl.

1440
1441
1442
1443
1444
1445
1446
1447









1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
    # Configuring input/output channels

    if {[llength $channels] == 5} {
        # command-fd and stdin are the same channel if CExecGPG is unavailable,
        # so, configure its encoding right before use
        fconfigure [lindex $channels 4] -buffering none
    }










    # stdin
    fconfigure [lindex $channels 0] -encoding $encoding -buffering none

    # stdout
    switch -- $operation {
        list-keys {
            fconfigure [lindex $channels 1] -encoding utf-8
        }
        sign -
        detach-sign -
        encrypt {
            if {!$armor} {
                fconfigure [lindex $channels 1] -translation binary
            } else {
                fconfigure [lindex $channels 1] -encoding $encoding
            }
        }
        default {
            fconfigure [lindex $channels 1] -encoding $encoding
        }
    }

    # stderr is always in UTF-8
    fconfigure [lindex $channels 2] -encoding utf-8

    # status-fd is always in UTF-8








>
>
>
>
>
>
>
>
>

|












|



|







1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
    # Configuring input/output channels

    if {[llength $channels] == 5} {
        # command-fd and stdin are the same channel if CExecGPG is unavailable,
        # so, configure its encoding right before use
        fconfigure [lindex $channels 4] -buffering none
    }

    switch -- $encoding {
        binary {
            set encopt -translation
        }
        default {
            set encopt -encoding
        }
    }

    # stdin
    fconfigure [lindex $channels 0] $encopt $encoding -buffering none

    # stdout
    switch -- $operation {
        list-keys {
            fconfigure [lindex $channels 1] -encoding utf-8
        }
        sign -
        detach-sign -
        encrypt {
            if {!$armor} {
                fconfigure [lindex $channels 1] -translation binary
            } else {
                fconfigure [lindex $channels 1] $encopt $encoding
            }
        }
        default {
            fconfigure [lindex $channels 1] $encopt $encoding
        }
    }

    # stderr is always in UTF-8
    fconfigure [lindex $channels 2] -encoding utf-8

    # status-fd is always in UTF-8
1639
1640
1641
1642
1643
1644
1645

1646
1647

1648
1649
1650

1651
1652
1653
1654
1655
1656
1657
                    return
                } else {
                    # Passphrase encoding may differ from message encoding,
                    # so we have to save command-fd encoding in case when
                    # command-fd and stdin are the same channel.

                    set encoding [fconfigure $command_fd -encoding]

                    fconfigure $command_fd \
                        -encoding [Set $token -property passphrase-encoding]

                    puts $command_fd $passphrase
                    flush $command_fd
                    fconfigure $command_fd -encoding $encoding

                }
            }
            BAD_PASSPHRASE {
                set state(badpassphrase) 1
            }
            DECRYPTION_FAILED {
                FinishWithError $channels $commands "Decryption failed"







>

|
>


|
>







1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
                    return
                } else {
                    # Passphrase encoding may differ from message encoding,
                    # so we have to save command-fd encoding in case when
                    # command-fd and stdin are the same channel.

                    set encoding [fconfigure $command_fd -encoding]
                    set translation [fconfigure $command_fd -translation]
                    fconfigure $command_fd \
                        -encoding [Set $token -property passphrase-encoding] \
                        -translation auto
                    puts $command_fd $passphrase
                    flush $command_fd
                    fconfigure $command_fd -encoding $encoding \
                                           -translation $translation
                }
            }
            BAD_PASSPHRASE {
                set state(badpassphrase) 1
            }
            DECRYPTION_FAILED {
                FinishWithError $channels $commands "Decryption failed"