This repository has been archived on 2021-02-07. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
CismonX 4ae458f1b7
bug report
2021-02-07 22:12:09 +08:00
README.md bug report 2021-02-07 22:12:09 +08:00
button.c.patch bug report 2021-02-07 22:12:09 +08:00
test.c bug report 2021-02-07 22:12:09 +08:00

README.md

Bug Report for XTerm

Summary

With 1002 and 1016 mode enabled, XTerm may produce invalid CSI sequence.

Prerequisites

  • XTerm version: 365
  • XTerm configuration: default
  • Operating System: GNU/Linux

Steps to Reproduce

  1. Compile test.c with gcc -o test-xterm test.c.
  2. In XTerm, run script -I input.esc.
  3. Run ./test-xterm.
  4. Move mouse pointer into the terminal window.
  5. Press down mouse button (do not release yet).
  6. Move mouse pointer across the top or left border of the terminal window.
  7. Release mouse button.
  8. Press Ctrl+D to quit the test program.
  9. Execute exit to quit the script session.
  10. Run teseq -L input.esc | less.

Analyze the Input Log

In Teseq's output, you may see something like this:

: Esc [ < 32 ; 9 ; 492 M
: Esc [ < 32 ; 5 ; 492 M
: Esc [ < 32 ; 1 ; 492 M
: Esc [
|<32;-3;492M|
: Esc [
|<32;-5;492M|
: Esc [
|<32;-7;492M|

After the mouse pointer moves across the window border, XTerm prints the negative coordinates in the CSI sequence.

However, the hyphen character "-" is not a valid CSI parameter byte, according to ECMA-48.

Bugfix

The bug is caused by the following code in button.c:

// ...
    if (screen->extend_coords == SET_PIXEL_POSITION_MOUSE) {
    row = event->y - OriginY(screen);
    col = event->x - OriginX(screen);
    } else {
    /* Compute character position of mouse pointer */
    row = (event->y - screen->border) / FontHeight(screen);
    col = (event->x - OriginX(screen)) / FontWidth(screen);

    /* Limit to screen dimensions */
    if (row < 0)
        row = 0;
    else if (row > screen->max_row)
        row = screen->max_row;

    if (col < 0)
        col = 0;
    else if (col > screen->max_col)
        col = screen->max_col;
// ...

When 1016 mode is enabled, XTerm does not limit the coordinates to the screen dimensions, so that negative values may be produced.

Apply the patch button.c.patch to button.c to fix the bug.