From 89188ec5706a31d22333d7b91c035cff378ba756 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 8 Aug 2017 20:47:19 -0500 Subject: [PATCH 1/3] Tests/ANSI: add test for #1161 E_NOTICE in ANSI --- tests/Unit/File/ANSITest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index dbb67af0..7fa89d7f 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -28,4 +28,22 @@ class Unit_File_ANSITest extends PhpseclibTestCase $this->assertSame($ansi->getScreen(), $expected); } + + public function testLineOverflow() + { + $str = ''; + foreach (range('a', 'y') as $char) { + $str.= "$char\r\n"; + } + $str.= str_repeat('z', 100); + + $ansi = new File_ANSI(); + $ansi->appendString($str); + + $screen = $ansi->getScreen(); + + $lines = explode("\r\n", $screen); + $this->assertSame(24, count($lines)); + $this->assertSame(str_repeat('z', 80), $lines[22]); + } } From 5c792f6bc1fa8a5d26b43fb8200191c073637e15 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 8 Aug 2017 21:44:22 -0500 Subject: [PATCH 2/3] ANSI: fix E_NOTICE when overflowing text overflows screen vertical --- phpseclib/File/ANSI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index eb6b8383..0cbed173 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -446,7 +446,7 @@ class File_ANSI if ($this->x > $this->max_x) { $this->x = 0; - $this->y++; + $this->_newLine(); } else { $this->x++; } From a9cd28d8fdbddf81bb08b76a3d9ad4406b7a8e27 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 8 Aug 2017 21:53:37 -0500 Subject: [PATCH 3/3] Tests/ANSI: update test for 2.0 branch --- tests/Unit/File/ANSITest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index a699446d..ac582532 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -37,7 +37,7 @@ class Unit_File_ANSITest extends PhpseclibTestCase } $str.= str_repeat('z', 100); - $ansi = new File_ANSI(); + $ansi = new ANSI(); $ansi->appendString($str); $screen = $ansi->getScreen();