Skip to content

Commit 9e1e691

Browse files
committed
HTML API: Preserve ::set_modifiable_text() TEXTAREA leading newlines.
HTML specifies that a single newline is ignored at the start of a `TEXTAREA`. If `::set_modifiable_text()` is called with a leading newline, ensure it is preserved in the resulting HTML. Developed in WordPress/wordpress-develop#11062. Props jonsurrell, dmsnell. See #64609. Built from https://develop.svn.wordpress.org/trunk@61754 git-svn-id: http://core.svn.wordpress.org/trunk@61060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent dded7c7 commit 9e1e691

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,6 +3877,17 @@ static function ( $tag_match ) {
38773877
$plaintext_content
38783878
);
38793879

3880+
/*
3881+
* HTML ignores a single leading newline in this context. If a leading newline
3882+
* is intended, preserve it by adding an extra newline.
3883+
*/
3884+
if (
3885+
'TEXTAREA' === $this->get_tag() &&
3886+
1 === strspn( $plaintext_content, "\n\r", 0, 1 )
3887+
) {
3888+
$plaintext_content = "\n{$plaintext_content}";
3889+
}
3890+
38803891
/*
38813892
* These don't _need_ to be escaped, but since they are decoded it's
38823893
* safe to leave them escaped and this can prevent other code from

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-beta2-61753';
19+
$wp_version = '7.0-beta2-61754';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)