diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 07624d60..6c42ef1f 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -419,7 +419,7 @@ class ANSI if ($this->x > $this->max_x) { $this->x = 0; - $this->y++; + $this->newLine(); } else { $this->x++; } diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index 3f6e607e..5f356e11 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -44,4 +44,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 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]); + } +} \ No newline at end of file