Fix Plaintext class

pull/14559/head
Art4 2024-11-19 09:05:55 +00:00
parent 2ff280d34c
commit c311a65073
2 changed files with 16 additions and 14 deletions

View File

@ -244,13 +244,12 @@ class Plaintext
$part = ''; $part = '';
$break_pos = 0; $break_pos = 0;
$comma_pos = 0; $comma_pos = 0;
$pos = 0;
$word = '';
$limit = $baselimit; $limit = $baselimit;
while ($message) { while ($message) {
$word = $message;
$message = '';
$pos = 0;
$pos_word = mb_strpos($message, ' '); $pos_word = mb_strpos($message, ' ');
$pos_paragraph = mb_strpos($message, "\n"); $pos_paragraph = mb_strpos($message, "\n");
@ -260,6 +259,9 @@ class Plaintext
$pos = $pos_word + 1; $pos = $pos_word + 1;
} elseif ($pos_paragraph !== false) { } elseif ($pos_paragraph !== false) {
$pos = $pos_paragraph + 1; $pos = $pos_paragraph + 1;
} else {
$word = $message;
$message = '';
} }
if (trim($message)) { if (trim($message)) {

View File

@ -32,17 +32,17 @@ class PlaintextTest extends FixtureTest
'Ich ignoriere auch Anfragen, wenn sie von Accounts kommen, die ggf. tausenden von anderen Accounts folgen, da ich davon ausgehe, (5/6)', 'Ich ignoriere auch Anfragen, wenn sie von Accounts kommen, die ggf. tausenden von anderen Accounts folgen, da ich davon ausgehe, (5/6)',
'dass da niemand ernsthaft so vielen Accounts folgen kann. (6/6)' 'dass da niemand ernsthaft so vielen Accounts folgen kann. (6/6)'
], ],
'test-2' => [ ],
'data' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.', 'test-2' => [
'expected' => [ 'data' => 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, (1/6)', 'expected' => [
'sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. (2/6)', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, (1/6)',
'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. (3/6)', 'sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. (2/6)',
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, (4/6)', 'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. (3/6)',
'sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. (5/6)', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, (4/6)',
'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. (6/6)' 'sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. (5/6)',
], 'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. (6/6)'
] ],
], ],
]; ];
} }