[php-src] PR #24116: Fix wordwrap() ignoring an existing break at the end of the string

From: Date: Sun, 04 Oct 2026 13:08:41 +0000
Subject: [php-src] PR #24116: Fix wordwrap() ignoring an existing break at the end of the string
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-39127@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/24116 Author: nicolas-grekas With $cut_long_words or a multi-character $break, wordwrap() treats a break that ends the string as regular text, while the same break anywhere else is kept as is: ```php wordwrap("abc\n", 3, "\n", true); // "abc\n\n" instead of "abc\n" wordwrap("ab cd\n", 5, "\n", true); // "ab\ncd\n" instead of "ab cd\n" wordwrap("ab cd\r\n", 5, "\r\n"); // "ab\r\ncd\r\n" instead of "ab cd\r\n" wordwrap("\r\n", 1, "\r\n", true); // "\r\r\n\n" instead of "\r\n" ``` The existing-break check used current + breakchar_len < len, so a break needed one more character after it to be recognized. <= is the right bound for the strncmp() that follows. The single-character fast path doesn't have this off-by-one, which is why cut and no-cut disagree. Found by @SulimanAbdulrazzaq in symfony/symfony#66572, which works around it.

« previous php.git-pulls (#39127) next »