1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-24 14:26:29 -05:00

7498 Commits

Author SHA1 Message Date
Simon Tatham
d1ff568533 Add some exceptions in .gitignore.
A user reports that our top-level .gitignore ignores several files
that are actually part of the real git repository. This is
inconvenient if you start from a downloaded tarball or zip file, and
try to make it _back_ into a git repository to work with it.

The blanket rule to ignore files called "Makefile" (on the theory that
they're autogenerated by cmake, or in the pre-cmake days, by
autotools) was also excluding two handwritten Makefiles, in 'icons'
and in 'contrib/cygtermd'. And the rule about doc/*.txt, intended to
exclude Halibut's plain-text output, also excluded doc/CMakeLists.txt.

With these exclusions in place, if you download a PuTTY source
.tar.gz, unpack it, change into the unpacked subdirectory, and run
'git init', 'git add .' and 'git commit', then 'git status --ignored'
to see what files in the tarball weren't added to the repo, you'll
find that the remaining ones are all in the 'doc' directory, and
really _are_ Halibut outputs: all the man pages (putty.1 etc), the
Windows help file putty.chm, and the plain text puttydoc.txt.
2025-04-19 13:14:53 +01:00
Ben Harris
9fcff77767 Set ATTR_RIGHTCURS on pre-edit cursor
Currently, we display the cursor at the right-hand end of the pre-edit
text.  That looks good for block and underline cursors, but it's a bit
weird for the vertical line, which naturally appears at the left edge
of the rightmost character.  Setting ATTR_RIGHTCURS fixes this and
means that the vertical-line cursor appears at the right edge of the
rightmost character.

That also corrects a weirdness where ATTR_RIGHTCURS was leaking
through from the underlying pending-wrap state of the terminal, which
was definitely wrong.
2025-04-06 13:37:14 +01:00
Simon Tatham
368d74cc25 Remove two unused variables.
They caused build failures at -Wall.
2025-04-06 06:39:26 +01:00
Ben Harris
fee594798f Remove recently-added debug() calls from terminal.c 2025-04-05 21:31:53 +01:00
Ben Harris
4f4f752e47 Put the cursor at the right-hand end of the pre-edit string
That's the more logical location in a string more than one character
long.  GTK does actually tell us where it thinks the cursor should be,
but we don't yet pay attention to that.
2025-04-05 21:31:53 +01:00
Ben Harris
6532408ba5 Support combining characters in pre-edit strings
Having the pre-edit string in a termline makes this almost trivial.
2025-04-05 21:31:53 +01:00
Ben Harris
d8493c11cd Construct preedit_termline incrementally
This involves repeatedly resizing it as we decode characters.  That's a
bit inefficient (at least with the current implementation of
resizeline()), but it makes it much easier to be certain that the line
is actually the right length.
2025-04-05 21:31:53 +01:00
Ben Harris
4776885767 Use a little termline to store pre-edit text
I think supporting combining characters in pre-edit text will be simpler
if I can use add_cc, which operated on termlines.  Also we have code for
resizing termlines, which means I might not need to count the width of
the pre-edit string accurately before allocating it.
2025-04-05 21:31:53 +01:00
Ben Harris
3bbde58c09 Properly hide existing combining characters with pre-edit text
If a character cell under the pre-edit text has a combining character,
it shouldn't be combined with a character from the pre-edit text, but
should be hidden instead.  This also means that the pre-edit text
could contain combining characters if I implemented a way to put them
into it.
2025-04-05 21:31:53 +01:00
Ben Harris
29ac4da8fb Support longer pre-edit text
Now the pre-edit text is converted into a dynamically-allocated array of
termchars in term_set_preedit_text(), which slightly simplifies
do_paint().  This means that the long pre-edit generated by Ctrl+Shift+U
in GNOME now displays more or less properly.  I may need a better plan
for what to do about cursor positioning, though.
2025-04-05 21:31:53 +01:00
Ben Harris
f9928fb7d5 Initialise pre-edit character cells to basic_erase_char
This ensures that they have sensible attributes (not black on black)
and is simpler than initialising the fields by hand.
2025-04-05 21:31:53 +01:00
Ben Harris
3ab279fae5 Minimal viable pre-edit support
Now we can cope with a single wide or narrow pre-edit character, which
is good enough for the input methods that I use.  When rendering the
line that contains the cursor we set up a little array of termchars
that contains the pre-edit text and work out where it should be
displayed.  Then when rendering the screen we switch between
displaying text from the real terminal and from the pre-edit string as
necessary.

Ideally, we should support longer strings, combining characters, and
setting attributes.  I think the current architecture should make all
of those possible, but not entirely easy.
2025-04-05 21:31:53 +01:00
Ben Harris
b72fec0a52 Display some IM pre-edit state when painting the terminal
This is approximately how it should work: term_set_preedit_text stashes
data in the terminal structure and then do_paint() renders it in place
of what's in the terminal buffer.  Currently this only works for a
single narrow character, and it copies the existing attributes under the
cursor, but this might actually be enough for the UK keyboard layout in
GNOME.
2025-04-05 21:31:53 +01:00
Ben Harris
ab9dfc572e Very crude support for displaying pre-edit strings
We simply pass each character to term_display_graphic_char and then
put the cursor back where we found it.  This works in simple cases,
but is fundamentally wrong.  Really we should do this in a way that
doesn't touch the terminal state and just gets rendered on top of it
somehow.
2025-04-05 21:31:53 +01:00
Ben Harris
35caff4048 Decode UTF-8 in pre-edit text
This is a pre-requisite to rendering it somehow.
2025-04-05 21:31:53 +01:00
Ben Harris
194ca31cc3 Add an API for passing pre-edit text to terminal; call from GTK
The terminal code doesn't yet do anything with the text other than feed
it to a debugging printf.  The call uses UTF-8 and expects the terminal
to copy the string because that's compatible with
gtk_im_context_get_preedit_string().
2025-04-05 21:31:53 +01:00
Ben Harris
227b9ae470 GTK: also log the preedit string 2025-04-05 21:31:53 +01:00
Ben Harris
fbea30bbaf GTK: trivially handle preedit signals
At present, that just means logging them when KEY_EVENT_DIAGNOSTICS is
defined.
2025-04-05 21:31:53 +01:00
Simon Tatham
6332497afb test_unicode_norm: fix display of failing tests.
There was a bytes / array elements confusion in the code that prints
out the input and output Unicode strings when a test fails. It was
using a loop with index variable 'pos', which was used as an array
index, but incremented by sizeof(a character) each time, leading to
only every fourth character actually being printed.

I assume this is leftover confusion from when I hadn't quite decided
whether to abuse the char-based strbuf for these Unicode character
buffers, or make a specialist type.

Discovered when I reached for this test program just now in order to
manually decompose a Unicode string. It doesn't have a convenient CLI
for that, but it was a thing I already knew where to find!
2025-04-04 23:05:51 +01:00
Ben Harris
7a100534d3 Rename cursor attributes from the TATTR_ to the ATTR_ namespace
No functional change.
2025-04-03 21:27:50 +01:00
Ben Harris
f2d63388a8 Stop cursor attributes being temporary
When telling front ends to paint the screen, the terminal code treats
the cursor as an attribute applied to the character cell(s) it appears
in.  do_paint() detects changes to most such attributes by storing what
it last sent to the front end in term->disptext and comparing that with
what it thinks should be displayed in the window. However, before this
commit the cursor was special.  Its last-drawn position was recorded in
special structure members and invalidated parts of the display based on
those.  The cursor attributes were treated as "temporary attributes" and
were not saved in term->disptext.

This commit regularizes this and turns the cursor attributes into normal
attributes that are stored in term->disptext.  This removes a bunch of
special-case code in do_paint() because now the normal update code
handles the cursor properly, and also removes some members from the
Terminal structure.  I hope it will also make future cursor-handling
changes (for instance for input method pre-editing) simpler.

This commit makes the required semantic changes but doesn't make the
rather more pervasive change of actually renaming the attributes from
TATTR_ to ATTR_.  That will be in the next commit.
2025-04-03 21:27:36 +01:00
Simon Tatham
7f96069954 Use _Countof to implement lenof, where available.
Up-to-date trunk clang has introduced a built-in operator called
_Countof, which is like the 'lenof' macro in this code (returns the
number of elements in a statically-declared array object) but with the
safety advantage that it provokes a compile error if you accidentally
use it on a pointer. In this commit I add a cmake-time check for it,
and conditional on that, switch over the definition of lenof.

This should add a safety check for accidental uses of lenof(pointer).
When I tested it with new clang, this whole code base compiled cleanly
with the new setting, so there aren't currently any such accidents.

clang cites C2y as the source for _Countof: WG14 document N3369
initially proposed it under a different name, and then there was a big
internet survey about naming (in which of course I voted for lenof!),
and document N3469 summarises the results, which show that the name
_Countof and/or countof won. Links:

  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3369.pdf
  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3469.htm

My reading of N3469 seems to say that there will _either_ be _Countof
by itself, _or_ lowercase 'countof' as a new keyword, but they don't
say which. They say they _don't_ intend to do the same equivocation we
had with _Complex and _Bool, where you have a _Countof keyword and an
optional header file defining a lowercase non-underscore macro
wrapping it. But there hasn't been a new whole draft published since
N3469 yet, so I don't know what will end up in it when there is.

However, as of now, _Countof exists in at least one compiler, and that
seems like enough reason to implement it here. If it becomes 'countof'
in the real standard, then we can always change over later. (And in
that case it would probably make sense to rename the macro throughout
the code base to align with what will become the new standard usage.)
2025-04-03 12:35:37 +01:00
Ben Harris
5ef7f2eaf0 Correct a comment referring to Contexts, which we no longer have 2025-04-01 23:03:34 +01:00
Ben Harris
e98071dd38 GTK: tell the input method context about focus changes
GtkIMContext has focus_in and focus_out methods for telling it when the
corresponding widget gains or loses keyboard focus.  It's not obvious to
me why these are necessary, but PuTTY now calls them when it sees
focus-in and focus-out events for the terminal window.  Somehow, this
has caused Hangul input to start working in PuTTY. I can't yet
see what I'm typing for lack of proper preedit support, though.
2025-03-28 13:55:34 +00:00
Ben Harris
c229a5e177 Remove residual declaration of term_key() and related constants
term_key() itself was removed in 2012, but its relations in putty.h
somehow survived.
2025-03-28 13:55:02 +00:00
Johannes Altmanninger
2b00d599d3 Parse DCS commands too
[ECMA-48] section 8.3.27 specifies the format of Device Control String
(DCS) commands which are used for XTGETTCAP and other sequences.

We don't parse DCS commands. This causes this command to wrongly
output some characters:

    printf '\033P+q616d\033\\'

Fix that by parsing DCS commands just like other OSC-like commands.
(Apart from the initial characters, DCS has the same format as OSC.)

We also allow 0x07 as sequence terminator which does not seem specified
but a lot of people use it with OSC; it's fine because 0x07 is not
allowed in the OSC/DCS payload.

[ECMA-48]: https://www.ecma-international.org/wp-content/uploads/ECMA-48_2nd_edition_august_1979.pdf
2025-03-27 07:46:31 +00:00
Jacob Nevins
24a2ede773 Docs: mention certificates in faq-hostkeys. 2025-03-17 23:34:47 +00:00
Simon Tatham
feaadd90ea SVG icons: adjust the hat on the Pageant icon.
It was a bit far to the right, looking at risk of falling off. Now
moved it as far left as it will go without the top right corner of the
computer monitor peeking out from behind it.
2025-03-11 21:43:54 +00:00
Simon Tatham
0a77b18481 SVG icons: support black-and-white mode.
If I'm going to use this as a means of generating bitmap icons at
large sizes, I want it to support all the same modes as the existing
bitmap script. So this adds a mode to the SVG generator that produces
the same black and white colour scheme as the existing monochrome
bitmap icons.

(Plus, who knows, the black and white SVGs might come in useful for
other purposes. Printing as a logo on black-and-white printers springs
to mind.)

The existing monochrome icons aren't greyscale: all colours are
literally either black or white, except for the cardboard box in the
installer icon, which is halftoned. Here I've rendered that box as
mid-grey. When I convert the rendered SVG output to an actual
1-bit (plus alpha) image, I'll have to redo that halftoning.
2025-03-08 12:01:28 +00:00
Simon Tatham
a3cd2a5724 SVG icons: fix computer/monitor alignment.
It looked nasty that the back corner of the monitor didn't line up
exactly with the outline of the system box behind it. Now I choose the
y offset between the two components to ensure it does. Also adjusted
the monitor's depth so that it fits better with the new alignment.
2025-03-08 11:53:43 +00:00
Simon Tatham
308a85f8a2 icons: build true-colour installer icons unconditionally.
We weren't building _all_ the icons in true-colour mode, because most
don't change anyway. The installer ones do, so let's build them. Works
better with the preview page.
2025-03-08 11:53:41 +00:00
Simon Tatham
58b0fbfe3a icons: HTML preview page.
This is a convenient thing to look at in a web browser, via a file://
URL, which lets me see all the icons together and check they match.
2025-03-08 11:53:00 +00:00
Simon Tatham
0ea6a31abd icons: gitignore update for SVG files. 2025-03-08 11:53:00 +00:00
Simon Tatham
64712be3cb Non-SSH backends: delay setting trust status to false.
A user reported recently that if you connect to a Telnet server via a
proxy that requires authentication, and enter the auth details
manually in the PuTTY terminal window, then the entire Telnet session
is shown with trust sigils to its left.

This happens because telnet.c calls seat_set_trust_status(false) as
soon as it's called new_connection() to make the Socket. But the
interactive proxy authentication dialogue hasn't happened yet, at that
point. So the proxy resets the trust status to true and asks for a
username and password, and then nothing ever resets it to false,
because telnet.c thought it had already done that.

The solution is to defer the Telnet backend's change of trust status
to when we get the notification that the socket is properly connected,
which arrives via plug_log(PLUGLOG_CONNECT_SUCCESS).

The same bug occurs in raw.c and supdup.c, but not in rlogin.c,
because Rlogin has an initial authentication exchange known to the
protocol, and already delays resetting the trust status until after
that has concluded.
2025-02-27 12:51:18 +00:00
Simon Tatham
965057d6d6 Change strategy for the Arm instruction setting DIT.
Colin Watson reported that a build failure occurred in the AArch64
Debian build of PuTTY 0.83:

gcc now defaults to enabling branch protection using AArch64 pointer
authentication, if the target architecture version supports it.
Debian's base supported architecture does not, but Armv8.4-A does. So
when I changed the compile flags for enable_dit.c to add
-march=armv8.4-a, it didn't _just_ allow me to write the 'msr dit, %0'
instruction in my asm statement; it also unexpectedly turned on
pointer authentication in the containing function, which caused a
SIGILL when running on a pre-Armv8.4-A CPU, because although the code
correctly skipped the instruction that set DIT, it was already inside
enable_dit() at that point and couldn't avoid going through the
unsupported 'retaa' instruction which tries to check an auth code on
the return address.

An obvious approach would be to add -mbranch-protection=none to the
compile flags for enable_dit.c. Another approach is to leave the
_compiler_ flags alone, and change the architecture in the assembler,
either via a fiddly -Wa,... option or by putting a .arch directive
inside the asm statement. But both have downsides. Turning off branch
protection is fine for the Debian build, but has the unwanted side
effect of turning it off (in that one function) even in builds
targeting a later architecture which _did_ want branch protection. And
changing the assembler's architecture risks changing it _down_ instead
of up, again perhaps invalidating other instructions generated by the
compiler (like if some later security feature is introduced that gcc
also wants to turn on by default).

So instead I've taken the much simpler approach of not bothering to
change the target architecture at all, and instead generating the move
into DIT by hardcoding its actual instruction encoding. This meant I
also had to force the input value into a specific register, but I
don't think that does any harm (not _even_ wasting an extra
instruction in codegen). Now we should avoid interfering with any
security features the compiler wants to turn on or off: all of that
should be independent of the instruction I really wanted.
2025-02-15 15:57:53 +00:00
Jacob Nevins
50e360fc74 Docs: belated updates for protocol controls.
Some of our words weren't updated when the less-frequently used
protocols like 'Raw' were moved to a drop-down.
2025-02-11 23:56:56 +00:00
Jacob Nevins
1c86360a03 Docs: clarify wording about host key staleness.
I stumbled over this paragraph on a re-read.
2025-02-11 23:52:24 +00:00
Jacob Nevins
b205622789 Docs: index some missing command-line options.
In PuTTYgen and Pageant.
2025-02-11 23:48:16 +00:00
Jacob Nevins
188d7c9685 Docs: consistent indexing of command-line options.
We used to have a practice of \IM-ing every command-line option for the
index, but haven't kept it up.
Add these for all existing indexed command-line options, plus some
related tidying.
2025-02-11 20:46:35 +00:00
Jacob Nevins
54648a161e Docs: consistently use \- for options.
(That's Halibut's non-breaking hyphen.)
Triggered by noticing that the changes in 54f6fefe61 happened to come
out badly in the text-only rendering, but I noticed there were many more
instances in the main docs where non-breaking hyphens would help.
2025-02-11 20:44:54 +00:00
Jacob Nevins
5814bdf529 Docs: replace long-dead link for Netcat. 2025-02-11 20:40:18 +00:00
Jacob Nevins
ee72268b8f Docs: improve -share/-noshare docs.
These options apply to many PuTTY tools, not just Plink; the indexing
was wonky; and -noshare wasn't documented at all.
2025-02-11 20:38:49 +00:00
Simon Tatham
267f077fcc Reorganise the release checklist.
After all these years, this checklist is _still_ hard for me to get
right. In the 0.83 runup this month, I prepared everything about the
RC build in advance, but nothing about the announcements, website
updates etc, and had to do all of that on release day.

So I've completely removed the section "Preparing to make the
release", which was ambiguous about whether it's done in advance or on
the day. Now all the text parts (website, wishlist, announcements) are
folded into the "make a release candidate" section, in the hope that
I'll remember to do them all at the same time, which should mean

 - people have a few days to review the text _and_ test the RC build
 - because they go together, I also remember to revise the text if a
   new RC build is needed (e.g. mention whatever extra fix it has).

The "actual release procedure" section is now down to _only_ the
things I have to do on the day, which is basically uploading
everything, going live, and communicating the release.
2025-02-08 11:28:55 +00:00
Simon Tatham
edd9df9b3d Merge tag '0.83' 2025-02-08 10:29:48 +00:00
Simon Tatham
d2c178c49a Update version number for 0.83 release. 0.83 2025-02-01 11:16:55 +00:00
Simon Tatham
476ecf427a Merge kex-hybrid memory leak fix from 'pre-0.83' 2025-02-01 11:11:40 +00:00
Simon Tatham
8fb45f4617 kex-hybrid: fix a small memory leak on failure.
Spotted by Coverity: we've just allocated a strbuf to hold the output
of the classical half of the hybrid key exchange, but if that output
isn't generated due to some kind of failure, we forgot to free the
strbuf on exit.
2025-02-01 11:10:35 +00:00
Simon Tatham
da8241cff6 Remove test for, and fallback impl of, wmemchr.
This was introduced in commit e7acb9f6968d482, as a side effect of
also wanting to call wmemchr to find a NUL wide character in the
buffer returned from GetDlgItemTextW. But the previous commit has
superseded that code, so now we don't use wmemchr in this code base
any more. Remove the machinery that provides it, saving a now-useless
cmake configure-time check.
2025-01-26 11:49:42 +00:00
Simon Tatham
05a13d5cf7 GetDlgItemText_alloc: avoid realloc loop.
This rewrite, due to SATO Kentaro, uses GetWindowTextLength (which I
hadn't known about) to find the correct size to allocate the buffer
the first time, avoiding the need to keep growing it until a call to
GetDlgItemText doesn't have to truncate the result.
2025-01-25 11:09:20 +00:00
Simon Tatham
520fd3d820 Merge request_file buffer length fix from 'pre-0.83'. 2025-01-25 10:30:15 +00:00