diff --git a/README.md b/README.md
index 467d006..44fa678 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,23 @@ line falls out of the scrollback — and a resize does nothing to it at all. See
## Compliance

+## Behaviour changes
+
+**DECRQCRA is off by default.** `CSI Pid ; Pp ; Pt ; Pl ; Pb ; Pr * y` asks for a checksum of a
+rectangle of the screen. Asked one cell at a time, it gives back the text, so a program, or a remote
+host you've just ssh'd to, can read what was on screen before it started, alternate screen included.
+WezTerm turned it off for the same reason, xterm gates it behind `allowWindowOps`, and iTerm2 asks
+first. While it is off the request is ignored and nothing is sent back, which is what xterm and
+WezTerm do.
+
+esctest reads every cell back through DECRQCRA, so turn it back on for a conformance run:
+
+```csharp
+var terminal = new Terminal(new TerminalOptions { ChecksumReportsEnabled = true });
+// or, on a running terminal:
+terminal.Options.ChecksumReportsEnabled = true;
+```
+
## Upgrading to 3.0
**3.0 changes how Sixel is stored.** If you only host a terminal and draw text, or draw only Kitty
diff --git a/src/XTerm.NET.Tests/ChecksumReportTests.cs b/src/XTerm.NET.Tests/ChecksumReportTests.cs
index ef7578c..081646f 100644
--- a/src/XTerm.NET.Tests/ChecksumReportTests.cs
+++ b/src/XTerm.NET.Tests/ChecksumReportTests.cs
@@ -10,8 +10,36 @@ public class ChecksumReportTests
{
private const string Esc = "";
- private static Terminal NewTerminal(int cols = 20, int rows = 5) =>
- new(new TerminalOptions { Cols = cols, Rows = rows });
+ // Opted in, as an esctest run has to be: the report is off by default (tomlm/XTerm.NET#190).
+ private static Terminal NewTerminal(int cols = 20, int rows = 5, bool enabled = true) =>
+ new(new TerminalOptions { Cols = cols, Rows = rows, ChecksumReportsEnabled = enabled });
+
+ ///
+ /// Off by default: DECRQCRA reads the screen back one cell at a time, so a program could recover
+ /// what was displayed before it started. Like xterm and WezTerm when it is disallowed, the
+ /// request goes unanswered rather than drawing a reply that could pass for a sum.
+ ///
+ [Fact]
+ public void Is_silent_by_default()
+ {
+ var terminal = new Terminal(new TerminalOptions { Cols = 20, Rows = 5 });
+ terminal.Write("Hello");
+
+ Assert.Null(Reply(terminal, $"{Esc}[1;0;1;1;1;1*y"));
+ Assert.Null(Reply(terminal, $"{Esc}[1*y"));
+ }
+
+ [Fact]
+ public void Is_silent_when_disabled_and_answers_once_enabled()
+ {
+ var terminal = NewTerminal(enabled: false);
+ terminal.Write("Hello");
+ Assert.Null(Reply(terminal, $"{Esc}[1;0;1;1;1;1*y"));
+
+ // The option is read per request, so a host can turn it on for a running terminal.
+ terminal.Options.ChecksumReportsEnabled = true;
+ Assert.Equal(Report(1, 'H'), Reply(terminal, $"{Esc}[1;0;1;1;1;1*y"));
+ }
private static string? Reply(Terminal terminal, string sequence)
{
diff --git a/src/XTerm.NET.Tests/DeviceReportTests.cs b/src/XTerm.NET.Tests/DeviceReportTests.cs
index 9805492..ee5aca0 100644
--- a/src/XTerm.NET.Tests/DeviceReportTests.cs
+++ b/src/XTerm.NET.Tests/DeviceReportTests.cs
@@ -144,6 +144,7 @@ public void Decrqtsr_WithNoParameterAsksForNothing()
public void Decrqcra_IsSilentBelowLevel64()
{
var (terminal, replies) = Create();
+ terminal.Options.ChecksumReportsEnabled = true; // opt-in; the level gate is what's tested
terminal.Write(Esc + "[64\"p");
terminal.Write(Esc + "[1;0;1;1;1;1*y");
Assert.Single(replies); // answered at VT400
diff --git a/src/XTerm.NET.Tests/Options/TerminalOptionsTests.cs b/src/XTerm.NET.Tests/Options/TerminalOptionsTests.cs
index 59aed1e..36a2d31 100644
--- a/src/XTerm.NET.Tests/Options/TerminalOptionsTests.cs
+++ b/src/XTerm.NET.Tests/Options/TerminalOptionsTests.cs
@@ -39,6 +39,7 @@ public void Constructor_SetsDefaultValues()
Assert.Equal(RendererType.Canvas, options.RendererType);
Assert.True(options.ClipboardWriteEnabled);
Assert.False(options.ClipboardReadEnabled);
+ Assert.False(options.ChecksumReportsEnabled); // DECRQCRA reads the screen back: opt-in
Assert.NotNull(options.WindowOptions);
Assert.NotNull(options.Theme);
Assert.Equal(1, options.MinimumContrastRatio);
diff --git a/src/XTerm.NET.Tests/VtTestBehaviourTests.cs b/src/XTerm.NET.Tests/VtTestBehaviourTests.cs
index 440dcf3..79ab744 100644
--- a/src/XTerm.NET.Tests/VtTestBehaviourTests.cs
+++ b/src/XTerm.NET.Tests/VtTestBehaviourTests.cs
@@ -170,6 +170,7 @@ public void A_tab_stop_can_be_set_and_landed_on()
public void Rectangular_area_checksums_negate_the_sum_of_the_characters()
{
var terminal = Sized(20, 5);
+ terminal.Options.ChecksumReportsEnabled = true; // vttest's checksum test needs the opt-in
var replies = new List();
terminal.DataReceived += (_, e) => replies.Add(e.Data);
diff --git a/src/XTerm.NET/InputHandler.Csi.cs b/src/XTerm.NET/InputHandler.Csi.cs
index 2ace064..0e03423 100644
--- a/src/XTerm.NET/InputHandler.Csi.cs
+++ b/src/XTerm.NET/InputHandler.Csi.cs
@@ -1753,6 +1753,11 @@ private void RequestChecksumRectangularArea(Params parameters)
if (!RectangularEditingAvailable)
return;
+ // A read-back of the screen, so opt-in; see TerminalOptions.ChecksumReportsEnabled. Silent
+ // when off, as xterm and WezTerm are, rather than a reply that could be mistaken for a sum.
+ if (!_terminal.Options.ChecksumReportsEnabled)
+ return;
+
var id = parameters.GetParam(0, 0);
// parameters[1] is the page, ignored. Coordinates are read in the ORIGIN MODE system,
// like a cursor address and like every rectangle operation: a program that addresses its
diff --git a/src/XTerm.NET/Options/TerminalOptions.cs b/src/XTerm.NET/Options/TerminalOptions.cs
index 982ea2d..fce44d8 100644
--- a/src/XTerm.NET/Options/TerminalOptions.cs
+++ b/src/XTerm.NET/Options/TerminalOptions.cs
@@ -254,6 +254,22 @@ public int TabStopWidth
///
public bool ClipboardReadEnabled { get; set; } = false;
+ ///
+ /// Whether DECRQCRA (CSI Pid ; Pp ; Pt ; Pl ; Pb ; Pr * y), the checksum of a
+ /// rectangular area, is answered.
+ ///
+ ///
+ /// Disabled by default for the same reason as : it is a
+ /// read-back. Checksumming one cell at a time recovers the screen's text, so a program -- or a
+ /// remote host the user has just ssh'd to -- can read what was displayed before it started,
+ /// including the alternate screen the last full-screen application left behind. WezTerm turned
+ /// it off for this reason, xterm gates it behind allowWindowOps, and iTerm2 asks first.
+ /// While off the request is ignored and nothing is sent, which is what xterm and WezTerm
+ /// do when it is disallowed. esctest reads every cell back through this, so a conformance run
+ /// needs it set true.
+ ///
+ public bool ChecksumReportsEnabled { get; set; } = false;
+
///
/// Whether control characters survive .
///
@@ -564,6 +580,7 @@ public TerminalOptions(TerminalOptions other)
KittyNotificationsEnabled = other.KittyNotificationsEnabled;
ClipboardWriteEnabled = other.ClipboardWriteEnabled;
ClipboardReadEnabled = other.ClipboardReadEnabled;
+ ChecksumReportsEnabled = other.ChecksumReportsEnabled;
AllowPasteControls = other.AllowPasteControls;
MaxClipboardBytes = other.MaxClipboardBytes;
KittyKeyboardEnabled = other.KittyKeyboardEnabled;