Commit cd0da45b3d9 for woocommerce

commit cd0da45b3d915f20f3288a929c3eacc4102baded
Author: Pavel Dohnal <pavel.dohnal@automattic.com>
Date:   Tue Nov 24 12:49:57 2026 +0100

    Show HTML personalization tag values as plain text in plain-text emails (#70817)

    * Convert HTML tag values to plain text in the text rendering context

    Tags with the default HTML value type were inserted untouched in the
    text context, so links, <strong>, <br>, lists and entities ended up in
    the plain-text body, the subject and the preheader. Integrators each
    wrote their own conversion.

    The Personalizer now runs such values through Html2Text, as the
    Renderer does for the body. Values with no tag or entity stay as they
    are, because Html2Text would cut text after a bare "<" (as in "<3").

    * Document the plain-text conversion of HTML tag values

    The developer guide said HTML-typed tag values are inserted untouched in
    plain-text output, which is no longer true. Also drop a string cast the
    callback's return type already guarantees and shorten the changelog.

    * Test that the value interceptor receives the converted plain text

    The interceptor docblock promises the value after plain-text conversion;
    this pins the order so moving the conversion after the interceptor fails.

    * Keep text after a bare "<" in converted tag values and document the rule

    Older libxml versions drop everything after a "<" that does not start
    a tag, so "Tom &amp; Jerry <3 you" became "Tom & Jerry". Such a "<" is
    now encoded before the conversion. The docs and the text context
    docblock now say an HTML-typed value is HTML in every context, and the
    changelog notes that value interceptors receive the converted text.

    * Convert subjects and preheaders to plain text with the HTML API

    wp_strip_all_tags() drops everything after a "<" that does not start a
    tag, so a subject like "I <3 Shoes" read "I", and now that tag values
    are decoded "I &lt;3 Shoes" did too. It also left entities such as
    &euro; in place. Html_Processing_Helper::get_plain_text() keeps text
    nodes only, decoded; WC_Email::get_subject() for block emails and the
    package's preheader use it.

    * Describe the visible subject and preheader changes in the changelogs

    Preheaders already showed entities correctly through esc_html(), so
    only the kept text after a "<" is visible there; the WooCommerce entry
    now names the symbols merchants see instead of entity codes.

    * Keep the space around converted HTML tag values

    Html2Text trims its output, so an HTML-typed tag that returns only
    "&nbsp;" vanished and "First&nbsp;Last" built from two tags read
    "FirstLast"; a value with spaces around markup lost them too. A space is
    now kept where the value started or ended with whitespace.

    * Convert the subject and preheader to text before filling in tags

    The subject was personalized and then parsed as HTML, so a tag value
    that is already plain text, such as "<em>Sale</em>" from an escaped
    HTML value, lost its tag-shaped text. The rich text is now converted
    first, keeping the tag comments, and the tags are filled in after; the
    preheader works the same way and is passed to the renderer escaped,
    since the renderer takes it as HTML.

    * Fill in subject and preheader tags while reading the text

    Converting the rich text first and then personalizing the result still
    parsed the merchant's text as HTML a second time, so a subject such as
    "a&lt;b" followed by a tag hid the tag. get_plain_text() now hands each
    tag comment to a callback and uses its value in place; WC_Email does
    this in one helper for the subject and preheader. The preheader is
    escaped with htmlspecialchars() on the way into and out of the
    template, so a literal "&lt;" stays literal.

    * Set the personalization context for block emails without subject tags

    The body of a block email is personalized with the context that the
    subject and preheader set up. Filling in only their tags meant a
    subject without tags left the body with an empty or stale context.
    The helper now sets the context for the email first, as before.

    * Personalize rich-text subjects with escape on insert, convert once

    Html_Processing_Helper knew the tag syntax and took a callback, which
    was hard to explain to integrators. Following Rosta's review, the
    Personalizer gets personalize_rich_text_as_plain_text(): tag values are
    escaped as they go into the rich text, so the field stays HTML until
    one get_plain_text() call converts it. TransactionalEmailPersonalizer
    wraps it with the email context for WC_Email's subject and preheader,
    and get_plain_text() goes back to having no callback.

    * Convert invoice and refund email subjects to plain text too

    The invoice, refunded-order and partially-refunded-order emails build
    their own subject and still filled in tags without converting the
    editor's rich text, so markup or entities could reach the customer.
    They now use the same rich-text-to-plain-text method as WC_Email, and
    the Personalizer imports these files no longer use are removed.

    * Expect converted text for an HTML tag argument in plain text

    With HTML tag values converted to plain text in the text context, the
    decoded <b>x</b> argument that an HTML tag outputs reads as x there.

    * Convert the POS refunded order subject to plain text too

    The POS refunded order email builds its own subject and, unlike the
    other block editor emails, never filled in its tags or converted the
    editor's rich text, so markup and tag comments could reach the
    customer. It now uses the same rich-text-to-plain-text method, after
    the subject filter as the refunded order email does.

diff --git a/packages/php/email-editor/changelog/add-personalize-rich-text-as-plain-text b/packages/php/email-editor/changelog/add-personalize-rich-text-as-plain-text
new file mode 100644
index 00000000000..8e7d0d8c83b
--- /dev/null
+++ b/packages/php/email-editor/changelog/add-personalize-rich-text-as-plain-text
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Add Personalizer::personalize_rich_text_as_plain_text() to personalize a rich-text subject or preheader as plain text.
diff --git a/packages/php/email-editor/changelog/fix-wooplug-8122-html-tag-values-plain-text b/packages/php/email-editor/changelog/fix-wooplug-8122-html-tag-values-plain-text
new file mode 100644
index 00000000000..4e3c438bb7c
--- /dev/null
+++ b/packages/php/email-editor/changelog/fix-wooplug-8122-html-tag-values-plain-text
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Show personalization tags that return HTML as plain text in plain-text emails, subjects and preheaders. Value interceptors receive the converted text.
diff --git a/packages/php/email-editor/changelog/fix-wooplug-8122-preheader-plain-text b/packages/php/email-editor/changelog/fix-wooplug-8122-preheader-plain-text
new file mode 100644
index 00000000000..ca7c34f5356
--- /dev/null
+++ b/packages/php/email-editor/changelog/fix-wooplug-8122-preheader-plain-text
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Keep the text after a “<” in email preheaders.
diff --git a/packages/php/email-editor/docs/personalization-tags.md b/packages/php/email-editor/docs/personalization-tags.md
index 86078971a5a..bf5a5224f30 100644
--- a/packages/php/email-editor/docs/personalization-tags.md
+++ b/packages/php/email-editor/docs/personalization-tags.md
@@ -126,7 +126,7 @@ The Personalizer passes the context of each replacement to the tag callback unde
 | Rendering context | Where the value lands | What the callback must return |
 | --- | --- | --- |
 | `Personalizer::RENDERING_CONTEXT_HTML` | HTML body content | An HTML fragment. Escape any dynamic data yourself (e.g. `esc_html()`) — unless the tag declares `VALUE_TYPE_TEXT`, in which case return raw text and the Personalizer escapes it (see [Value Type](#value-type)). |
-| `Personalizer::RENDERING_CONTEXT_TEXT` | Plain-text output (subject, preheader, plain-text body, `<title>`) | Raw plain text. No HTML markup, no entities, no escaping. |
+| `Personalizer::RENDERING_CONTEXT_TEXT` | Plain-text output (subject, preheader, plain-text body, `<title>`) | For `VALUE_TYPE_TEXT` tags, raw plain text. For `VALUE_TYPE_HTML` tags, HTML: the Personalizer converts it to plain text (see [Value Type](#value-type)). |
 | `Personalizer::RENDERING_CONTEXT_HREF` | A link URL (`href`) | A raw, unescaped URL — do not pre-escape; URL escaping is applied when the attribute is written. |

 In the text rendering context the Personalizer also replaces tags in the `[text](url)` link targets of the Renderer's plain-text version (in the href rendering context), and removes a tag comment it cannot resolve, because the recipient would see it as text. A link whose whole target is a tag it cannot resolve loses the target and reads `[text]`.
@@ -171,7 +171,9 @@ $registry->register(

 Note: the `esc_html()` call does not double-encode existing entities, so a raw text value that itself contains an entity-shaped sequence (e.g. a literal `&amp;`) renders as the decoded character (`&`). Always return genuinely raw text.

-The default, `Personalization_Tag::VALUE_TYPE_HTML`, inserts the value untouched in every rendering context — including plain-text output; the callback owns escaping and any per-context differences (in the `text` rendering context it must return raw plain text without markup or entities).
+The default, `Personalization_Tag::VALUE_TYPE_HTML`, inserts the value untouched in the `html` rendering context; the callback owns escaping and any per-context differences. In the `text` rendering context, a value that contains markup or HTML entities is converted to plain text with the same Html2Text conversion the Renderer uses for the plain-text body: links become `[text](url)`, line breaks and list items become lines, and entities are decoded. A value without markup or entities is inserted as it is.
+
+An HTML-typed value is HTML in every rendering context. A callback that returns plain text should escape it with `esc_html()` or declare `VALUE_TYPE_TEXT`; raw text such as `x<y` can otherwise read as markup and lose content.

 ## Value Interceptor

@@ -188,7 +190,7 @@ $previous = $personalizer->set_value_interceptor(

 The interceptor receives:

--   `$value` — the resolved value, after any context-driven escaping (e.g. `esc_html()` for `VALUE_TYPE_TEXT` tags in HTML content).
+-   `$value` — the resolved value, after any context-driven escaping or plain-text conversion (e.g. `esc_html()` for `VALUE_TYPE_TEXT` tags in HTML content, or the conversion of `VALUE_TYPE_HTML` values in the `text` rendering context).
 -   `$source` — the raw source text being replaced: the trimmed tag token including arguments, the raw `data-link-href` attribute value, or the tag token found inside a plain `href`.
 -   `$rendering_context` — the `RENDERING_CONTEXT_*` constant of the replacement site.

@@ -285,6 +287,7 @@ Main engine for replacing tags with values in email content.
 -   `set_context(array $context)`: Set the personalization context
 -   `get_context()`: Get the current context
 -   `personalize_content(string $content, string $rendering_context = Personalizer::RENDERING_CONTEXT_HTML)`: Process and personalize content; pass `Personalizer::RENDERING_CONTEXT_TEXT` for plain-text content such as subjects or plain-text bodies
+-   `personalize_rich_text_as_plain_text(string $rich_text)`: Personalize a field the editor stores as rich text, such as a subject or preheader, and return it as plain text in one pass
 -   `set_value_interceptor(?callable $interceptor)`: Register a callback intercepting each resolved value before it is written, or clear it with `null`; returns the previously registered interceptor (see [Value Interceptor](#value-interceptor))

 **Example Usage:**
diff --git a/packages/php/email-editor/src/Engine/PersonalizationTags/class-personalization-tag.php b/packages/php/email-editor/src/Engine/PersonalizationTags/class-personalization-tag.php
index a4e1904ed5d..996ab64aa63 100644
--- a/packages/php/email-editor/src/Engine/PersonalizationTags/class-personalization-tag.php
+++ b/packages/php/email-editor/src/Engine/PersonalizationTags/class-personalization-tag.php
@@ -16,7 +16,9 @@ namespace Automattic\WooCommerce\EmailEditor\Engine\PersonalizationTags;
 class Personalization_Tag {
 	/**
 	 * Value type for tags whose callback returns an HTML fragment appropriate to the rendering
-	 * context it receives. The Personalizer inserts the value untouched — the callback owns escaping.
+	 * context it receives. The Personalizer inserts the value untouched — the callback owns escaping —
+	 * except in the text rendering context, where a value with markup or entities is converted to
+	 * plain text (links become "[text](url)", line breaks and list items become lines).
 	 */
 	public const VALUE_TYPE_HTML = 'html';

diff --git a/packages/php/email-editor/src/Engine/Renderer/template-canvas.php b/packages/php/email-editor/src/Engine/Renderer/template-canvas.php
index 5c763ceab56..30ab4d0fb49 100644
--- a/packages/php/email-editor/src/Engine/Renderer/template-canvas.php
+++ b/packages/php/email-editor/src/Engine/Renderer/template-canvas.php
@@ -43,7 +43,7 @@ $language_attributes = trim( $language_attributes . ' dir="' . esc_attr( $render
 			<tbody>
 			<tr>
 				<td class="email_preheader" height="1">
-				<?php echo esc_html( wp_strip_all_tags( $pre_header ) ); ?>
+				<?php echo htmlspecialchars( \Automattic\WooCommerce\EmailEditor\Integrations\Utils\Html_Processing_Helper::get_plain_text( $pre_header ), ENT_QUOTES, 'UTF-8' ); ?>
 				</td>
 			</tr>
 			<tr>
diff --git a/packages/php/email-editor/src/Engine/class-personalizer.php b/packages/php/email-editor/src/Engine/class-personalizer.php
index 607f5642bc2..7ae55b75747 100644
--- a/packages/php/email-editor/src/Engine/class-personalizer.php
+++ b/packages/php/email-editor/src/Engine/class-personalizer.php
@@ -13,6 +13,8 @@ use Automattic\WooCommerce\EmailEditor\Engine\Logger\Email_Editor_Logger;
 use Automattic\WooCommerce\EmailEditor\Engine\PersonalizationTags\HTML_Tag_Processor;
 use Automattic\WooCommerce\EmailEditor\Engine\PersonalizationTags\Personalization_Tag;
 use Automattic\WooCommerce\EmailEditor\Engine\PersonalizationTags\Personalization_Tags_Registry;
+use Automattic\WooCommerce\EmailEditor\Engine\Renderer\Html2Text;
+use Automattic\WooCommerce\EmailEditor\Integrations\Utils\Html_Processing_Helper;

 /**
  * Class for replacing personalization tags with their values in the email content.
@@ -43,7 +45,7 @@ class Personalizer {

 	/**
 	 * Rendering context for plain-text content (e.g., email subject, preheader, plain-text body).
-	 * Tag values must be raw text without HTML entities or markup.
+	 * Text-typed tags return raw text; values of HTML-typed tags are converted to plain text.
 	 */
 	public const RENDERING_CONTEXT_TEXT = 'text';

@@ -169,7 +171,7 @@ class Personalizer {
 	/**
 	 * Set a callback intercepting each resolved personalization tag value before it is written.
 	 *
-	 * The interceptor receives the resolved value (after any context-driven escaping),
+	 * The interceptor receives the resolved value (after any context-driven escaping or plain-text conversion),
 	 * the raw source text being replaced (the trimmed tag token including arguments,
 	 * the raw data-link-href attribute value, or the tag token found inside a plain href),
 	 * and the rendering context of the replacement site — one of the RENDERING_CONTEXT_HTML,
@@ -235,6 +237,32 @@ class Personalizer {
 			$content = $this->personalize_text_link_targets( $content );
 		}

+		return $this->replace_tags( $content, $rendering_context, false );
+	}
+
+	/**
+	 * Personalize rich text, such as a subject or preheader edited in the editor, and return it as plain text.
+	 *
+	 * Tags get the text rendering context, and each value is escaped as it goes into the rich text, so the
+	 * field stays HTML until a single conversion to plain text at the end. Neither the author's text nor a
+	 * tag value is read as HTML twice. Unresolved tags and other comments are dropped.
+	 *
+	 * @param string $rich_text The rich text as stored by the editor.
+	 * @return string The personalized plain text.
+	 */
+	public function personalize_rich_text_as_plain_text( string $rich_text ): string {
+		return Html_Processing_Helper::get_plain_text( $this->replace_tags( $rich_text, self::RENDERING_CONTEXT_TEXT, true ) );
+	}
+
+	/**
+	 * Replace the personalization tags in the content with their values.
+	 *
+	 * @param string $content           The content to personalize.
+	 * @param string $rendering_context One of the RENDERING_CONTEXT_HTML or RENDERING_CONTEXT_TEXT constants.
+	 * @param bool   $escape_values     Whether to escape tag values for HTML as they are inserted.
+	 * @return string The personalized content.
+	 */
+	private function replace_tags( string $content, string $rendering_context, bool $escape_values ): string {
 		$content_processor = new HTML_Tag_Processor( $content );
 		while ( $content_processor->next_token() ) {
 			if ( $content_processor->get_token_type() === '#comment' ) {
@@ -257,9 +285,11 @@ class Personalizer {
 				$value = $this->get_tag_value( $tag, $rendering_context, $arguments );
 				if ( self::RENDERING_CONTEXT_HTML === $rendering_context && Personalization_Tag::VALUE_TYPE_TEXT === $tag->get_value_type() ) {
 					$value = esc_html( $value );
+				} elseif ( self::RENDERING_CONTEXT_TEXT === $rendering_context && Personalization_Tag::VALUE_TYPE_HTML === $tag->get_value_type() ) {
+					$value = $this->convert_html_value_to_text( $value );
 				}
 				$value = $this->intercept_value( (string) $value, trim( $modifiable_text ), $rendering_context );
-				$content_processor->replace_token( $value );
+				$content_processor->replace_token( $escape_values ? htmlspecialchars( $value, ENT_QUOTES, 'UTF-8' ) : $value );

 			} elseif ( $content_processor->get_token_type() === '#tag' && $content_processor->get_tag() === 'TITLE' ) {
 				// The title tag contains the subject of the email which should be personalized. HTML_Tag_Processor does parse the header tags.
@@ -325,6 +355,33 @@ class Personalizer {
 		);
 	}

+	/**
+	 * Convert an HTML tag value to plain text the same way the Renderer converts the plain-text body.
+	 * Values without markup or entities are returned untouched, so a bare "&" or "<3" and the
+	 * value's own whitespace survive.
+	 *
+	 * @param string $value The tag value.
+	 * @return string The plain-text value.
+	 */
+	private function convert_html_value_to_text( string $value ): string {
+		if ( ! preg_match( '/<[a-z!\/]|&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i', $value ) ) {
+			return $value;
+		}
+		// Encode a "<" that does not start a tag, or older libxml versions drop the text after it.
+		$value = (string) preg_replace( '/<(?![a-z!\/])/i', '&lt;', $value );
+		$text  = Html2Text::convert( $value, array( 'ignore_errors' => true ) );
+
+		// Html2Text trims its output, so keep a space where the value started or ended with one,
+		// otherwise a separator such as "&nbsp;" between two tags disappears.
+		$space    = '(?:\s|&nbsp;|&#160;|&#xa0;)';
+		$leading  = preg_match( '/^' . $space . '/i', $value ) ? ' ' : '';
+		$trailing = preg_match( '/' . $space . '$/i', $value ) ? ' ' : '';
+		if ( '' === $text ) {
+			return ( '' !== $leading . $trailing ) ? ' ' : '';
+		}
+		return $leading . $text . $trailing;
+	}
+
 	/**
 	 * Replace personalization tag tokens embedded in a link URL.
 	 *
diff --git a/packages/php/email-editor/src/Integrations/Utils/class-html-processing-helper.php b/packages/php/email-editor/src/Integrations/Utils/class-html-processing-helper.php
index d69586fe125..d14919d0759 100644
--- a/packages/php/email-editor/src/Integrations/Utils/class-html-processing-helper.php
+++ b/packages/php/email-editor/src/Integrations/Utils/class-html-processing-helper.php
@@ -721,6 +721,24 @@ class Html_Processing_Helper {
 		return '';
 	}

+	/**
+	 * Convert HTML to plain text for single-line fields such as a subject or preheader. Unlike
+	 * wp_strip_all_tags(), a "<" that does not start a tag keeps the text after it, and entities are decoded.
+	 *
+	 * @param string $html HTML or text.
+	 * @return string Plain text.
+	 */
+	public static function get_plain_text( string $html ): string {
+		$processor = new \WP_HTML_Tag_Processor( $html );
+		$text      = '';
+		while ( $processor->next_token() ) {
+			if ( '#text' === $processor->get_token_type() ) {
+				$text .= $processor->get_modifiable_text();
+			}
+		}
+		return trim( $text );
+	}
+
 	/**
 	 * Sanitize inline styles for image elements - only allow safe properties for email rendering.
 	 *
diff --git a/packages/php/email-editor/tests/integration/Engine/Personalizer_Test.php b/packages/php/email-editor/tests/integration/Engine/Personalizer_Test.php
index 31f984702d3..4944a5cd59a 100644
--- a/packages/php/email-editor/tests/integration/Engine/Personalizer_Test.php
+++ b/packages/php/email-editor/tests/integration/Engine/Personalizer_Test.php
@@ -681,7 +681,7 @@ class Personalizer_Test extends \Email_Editor_Integration_Test_Case {
 	}

 	/**
-	 * Test that an html value type tag (the default) is never touched by the Personalizer.
+	 * Test that an html value type tag (the default) is inserted untouched in the html rendering context.
 	 */
 	public function testHtmlValueTypeIsNotEscaped(): void {
 		$this->tags_registry->register(
@@ -711,10 +711,6 @@ class Personalizer_Test extends \Email_Editor_Integration_Test_Case {
 			'<p><span class="price">10 &euro;</span></p>',
 			$this->personalizer->personalize_content( $content, Personalizer::RENDERING_CONTEXT_HTML )
 		);
-		$this->assertSame(
-			'<p><span class="price">10 &euro;</span></p>',
-			$this->personalizer->personalize_content( $content, Personalizer::RENDERING_CONTEXT_TEXT )
-		);
 		// A tag emitting raw markup, such as a tracking pixel, is inserted verbatim.
 		$this->assertSame(
 			'<div><img src="https://track.example/open?id=42&amp;c=1" width="1" height="1" alt="" /></div>',
@@ -887,8 +883,9 @@ class Personalizer_Test extends \Email_Editor_Integration_Test_Case {
 			'<p>&lt;b&gt;x&lt;/b&gt; O&#039;Brien</p>',
 			$this->personalizer->personalize_content( '<p><!--[test/echo note="&lt;b&gt;x&lt;/b&gt;"]--> <!--[test/echo note="O&#039;Brien"]--></p>' )
 		);
+		// In plain text the decoded value is used, and the HTML tag's value is then converted to text.
 		$this->assertSame(
-			"<b>x</b> O'Brien",
+			"x O'Brien",
 			$this->personalizer->personalize_content( '<!--[test/echo note="&lt;b&gt;x&lt;/b&gt;"]--> <!--[test/echo note="O&#039;Brien"]-->', Personalizer::RENDERING_CONTEXT_TEXT )
 		);
 	}
@@ -955,6 +952,156 @@ class Personalizer_Test extends \Email_Editor_Integration_Test_Case {
 		);
 	}

+	/**
+	 * Values of html value type tags with markup or entities, and the plain text expected in the text rendering context.
+	 *
+	 * @return array<string, array{string, string}>
+	 */
+	public function htmlValueInTextContextProvider(): array {
+		return array(
+			'anchor'                    => array( '<a href="https://example.com/manage">Manage</a>', '[Manage](https://example.com/manage)' ),
+			'anchor with URL as text'   => array( '<a href="https://example.com">https://example.com</a>', 'https://example.com' ),
+			'strong'                    => array( '<strong>Bold</strong> text', 'Bold text' ),
+			'line break'                => array( 'Line one<br>Line two', "Line one\nLine two" ),
+			'list'                      => array( '<ul><li>One</li><li>Two</li></ul>', "- One\n- Two" ),
+			'entities'                  => array( 'Tom &amp; Jerry&#039;s', "Tom & Jerry's" ),
+			'markup and entities'       => array( '<span class="price">10&nbsp;&euro;</span>', '10 €' ),
+			'URL with encoded query'    => array( 'https://example.com/reset?key=a&amp;login=b', 'https://example.com/reset?key=a&login=b' ),
+			'plain text'                => array( 'Plain value', 'Plain value' ),
+			'bare ampersand'            => array( 'Tom & Jerry', 'Tom & Jerry' ),
+			'less-than sign'            => array( '5 <3 you', '5 <3 you' ),
+			'whitespace in plain text'  => array( "  Line one\nLine two ", "  Line one\nLine two " ),
+			'entity and bare less-than' => array( 'Tom &amp; Jerry <3 you', 'Tom & Jerry <3 you' ),
+			'markup and bare less-than' => array( '<em>a</em> < b', 'a < b' ),
+			'separator only'            => array( '&nbsp;', ' ' ),
+			'surrounding spaces kept'   => array( ' <b>x</b>&nbsp;', ' x ' ),
+		);
+	}
+
+	/**
+	 * Test that an html value type tag is converted to plain text in the text rendering context,
+	 * and left untouched when it holds no markup or entities.
+	 *
+	 * @dataProvider htmlValueInTextContextProvider
+	 * @param string $value    The tag value.
+	 * @param string $expected The expected plain text.
+	 */
+	public function testHtmlValueTypeIsConvertedToTextInTextContext( string $value, string $expected ): void {
+		$this->tags_registry->register(
+			new Personalization_Tag(
+				'html_value',
+				'test/html-value',
+				'Test',
+				function () use ( $value ) {
+					return $value;
+				}
+			)
+		);
+
+		$this->assertSame(
+			"Value: {$expected}.",
+			$this->personalizer->personalize_content( 'Value: <!--[test/html-value]-->.', Personalizer::RENDERING_CONTEXT_TEXT )
+		);
+		$this->assertSame(
+			"<p>Value: {$value}.</p>",
+			$this->personalizer->personalize_content( '<p>Value: <!--[test/html-value]-->.</p>' )
+		);
+	}
+
+	/**
+	 * Test that an html value type tag in the title is converted to plain text, while the body keeps the markup.
+	 */
+	public function testHtmlValueTypeIsConvertedToTextInTitle(): void {
+		$this->tags_registry->register(
+			new Personalization_Tag(
+				'order_number',
+				'test/order-number',
+				'Test',
+				function () {
+					return '<strong>#42</strong>';
+				}
+			)
+		);
+
+		$content = '<html><head><title>Order <!--[test/order-number]--></title></head><body><p><!--[test/order-number]--></p></body></html>';
+		$this->assertSame(
+			'<html><head><title>Order #42</title></head><body><p><strong>#42</strong></p></body></html>',
+			$this->personalizer->personalize_content( $content )
+		);
+	}
+
+	/**
+	 * Test that a text value type tag is not converted in the text rendering context.
+	 */
+	public function testTextValueTypeIsNotConvertedInTextContext(): void {
+		$this->tags_registry->register(
+			new Personalization_Tag(
+				'snippet',
+				'test/snippet',
+				'Test',
+				function () {
+					return 'Use <strong> &amp; <em>';
+				},
+				array(),
+				null,
+				array(),
+				Personalization_Tag::VALUE_TYPE_TEXT
+			)
+		);
+
+		$this->assertSame(
+			'Code: Use <strong> &amp; <em>',
+			$this->personalizer->personalize_content( 'Code: <!--[test/snippet]-->', Personalizer::RENDERING_CONTEXT_TEXT )
+		);
+	}
+
+	/**
+	 * Test that rich text such as a subject is personalized and converted to plain text in one pass,
+	 * so neither the author's text nor a tag value is read as HTML twice.
+	 */
+	public function testPersonalizeRichTextAsPlainText(): void {
+		$received = array();
+		$this->tags_registry->register(
+			new Personalization_Tag(
+				'Sale',
+				'test/sale',
+				'Test',
+				function ( $context ) use ( &$received ) {
+					$received[] = $context[ Personalizer::RENDERING_CONTEXT_KEY ];
+					return '&lt;em&gt;Sale&lt;/em&gt;';
+				}
+			)
+		);
+		$this->tags_registry->register(
+			new Personalization_Tag(
+				'Shop',
+				'test/shop',
+				'Test',
+				function () {
+					return 'Tom & Jerry <3';
+				},
+				array(),
+				null,
+				array(),
+				Personalization_Tag::VALUE_TYPE_TEXT
+			)
+		);
+		$intercepted = array();
+		$this->personalizer->set_value_interceptor(
+			function ( string $value ) use ( &$intercepted ): string {
+				$intercepted[] = $value;
+				return $value;
+			}
+		);
+
+		$this->assertSame(
+			'Big a<b <em>Sale</em> at Tom & Jerry <3 now',
+			$this->personalizer->personalize_rich_text_as_plain_text( '<strong>Big</strong> a&lt;b <!--[test/sale]--> at <!--[test/shop]--> <!--[other-plugin/x]--><!-- note -->now' )
+		);
+		$this->assertSame( array( Personalizer::RENDERING_CONTEXT_TEXT ), $received );
+		$this->assertSame( array( '<em>Sale</em>', 'Tom & Jerry <3' ), $intercepted );
+	}
+
 	/**
 	 * Test that the reserved rendering context key cannot be injected via set_context().
 	 */
@@ -1249,6 +1396,33 @@ class Personalizer_Test extends \Email_Editor_Integration_Test_Case {
 		$this->assertSame( 0, $calls );
 	}

+	/**
+	 * Test that the interceptor receives an html value type tag value already converted to plain text in the text rendering context.
+	 */
+	public function testValueInterceptorReceivesConvertedHtmlValueInTextContext(): void {
+		$this->tags_registry->register(
+			new Personalization_Tag(
+				'manage_link',
+				'test/manage-link',
+				'Test',
+				function () {
+					return '<a href="https://example.com/manage">Manage</a>';
+				}
+			)
+		);
+
+		$received = array();
+		$this->personalizer->set_value_interceptor(
+			function ( string $value ) use ( &$received ): string {
+				$received[] = $value;
+				return $value;
+			}
+		);
+
+		$this->personalizer->personalize_content( '<!--[test/manage-link]-->', Personalizer::RENDERING_CONTEXT_TEXT );
+		$this->assertSame( array( '[Manage](https://example.com/manage)' ), $received );
+	}
+
 	/**
 	 * Test that the interceptor receives the text rendering context for tags inside
 	 * <title> and the html rendering context for tags in the body.
diff --git a/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php b/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php
index 68c54aff8cc..77f6a0959b9 100644
--- a/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php
+++ b/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php
@@ -817,4 +817,12 @@ class Renderer_Test extends \Email_Editor_Integration_Test_Case {
 		list( , $text ) = $this->render_with_link_tag( '<!-- wp:paragraph --><p>Username: <strong><!--[other-plugin/username]--></strong>, <strong>Bold</strong></p><!-- /wp:paragraph -->' );
 		$this->assertStringContainsString( 'Username: <!--[other-plugin/username]-->, *Bold*', $text );
 	}
+
+	/**
+	 * Test that a preheader with a bare "<" keeps its text in the HTML email.
+	 */
+	public function testItKeepsPreheaderTextAfterLessThanSign(): void {
+		$rendered = $this->renderer->render( $this->email_post, 'Subject', 'I <3 Shoes &amp; more', 'en' );
+		$this->assertStringContainsString( 'I &lt;3 Shoes &amp; more', $rendered['html'] );
+	}
 }
diff --git a/packages/php/email-editor/tests/integration/Integrations/Utils/Html_Processing_Helper_Test.php b/packages/php/email-editor/tests/integration/Integrations/Utils/Html_Processing_Helper_Test.php
index 67d14539d1f..e6f5e25eb69 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Utils/Html_Processing_Helper_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Utils/Html_Processing_Helper_Test.php
@@ -18,6 +18,33 @@ use Automattic\WooCommerce\EmailEditor\Integrations\Utils\Html_Processing_Helper
  * the HTML API.
  */
 class Html_Processing_Helper_Test extends \Email_Editor_Integration_Test_Case {
+	/**
+	 * Plain text keeps a bare "<", drops real tags and decodes entities.
+	 *
+	 * @dataProvider plain_text_provider
+	 * @param string $html     Input HTML.
+	 * @param string $expected Expected plain text.
+	 */
+	public function test_get_plain_text( string $html, string $expected ): void {
+		$this->assertSame( $expected, Html_Processing_Helper::get_plain_text( $html ) );
+	}
+
+	/**
+	 * Data provider for plain text conversion.
+	 *
+	 * @return array<string, array{string, string}>
+	 */
+	public function plain_text_provider(): array {
+		return array(
+			'bare less-than'     => array( 'I <3 Shoes', 'I <3 Shoes' ),
+			'entities'           => array( 'Order&nbsp;#42 &euro; 1<2', "Order\u{00A0}#42 € 1<2" ),
+			'encoded less-than'  => array( 'I &lt;3 Shoes', 'I <3 Shoes' ),
+			'tags removed'       => array( '<strong>Order</strong> <em>#42</em> shipped', 'Order #42 shipped' ),
+			'comment removed'    => array( 'Hi <!-- note -->there', 'Hi there' ),
+			'surrounding spaces' => array( '  Plain value ', 'Plain value' ),
+		);
+	}
+
 	/**
 	 * Dangerous caption markup must be neutralized against the real HTML API.
 	 *
diff --git a/plugins/woocommerce/changelog/fix-wooplug-8122-subject-plain-text b/plugins/woocommerce/changelog/fix-wooplug-8122-subject-plain-text
new file mode 100644
index 00000000000..62cc69870fe
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-wooplug-8122-subject-plain-text
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Keep the text after a “<” in subjects of block editor emails, and show symbols such as € instead of their codes.
diff --git a/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php b/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php
index 513315d034a..bb95e121588 100644
--- a/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php
+++ b/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php
@@ -5,7 +5,6 @@
  * @package WooCommerce\Emails
  */

-use Automattic\WooCommerce\EmailEditor\Engine\Personalizer;
 use Automattic\WooCommerce\Enums\OrderStatus;
 use Automattic\WooCommerce\Utilities\FeaturesUtil;

@@ -92,7 +91,7 @@ if ( ! class_exists( 'WC_Email_Customer_Invoice', false ) ) :
 				$subject = $this->get_option( 'subject_paid', $this->get_default_subject( true ) );

 				if ( $this->block_email_editor_enabled ) {
-					$subject = $this->personalizer->personalize_transactional_content( $subject, $this, Personalizer::RENDERING_CONTEXT_TEXT );
+					$subject = $this->personalizer->personalize_transactional_rich_text_as_plain_text( $subject, $this );
 				}

 				return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $subject ), $this->object, $this );
@@ -101,7 +100,7 @@ if ( ! class_exists( 'WC_Email_Customer_Invoice', false ) ) :
 			$subject = $this->get_option( 'subject', $this->get_default_subject() );

 			if ( $this->block_email_editor_enabled ) {
-				$subject = $this->personalizer->personalize_transactional_content( $subject, $this, Personalizer::RENDERING_CONTEXT_TEXT );
+				$subject = $this->personalizer->personalize_transactional_rich_text_as_plain_text( $subject, $this );
 			}

 			return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $subject ), $this->object, $this );
diff --git a/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php b/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php
index d7733010d11..275502fc4fa 100644
--- a/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php
+++ b/plugins/woocommerce/includes/emails/class-wc-email-customer-partially-refunded-order.php
@@ -5,8 +5,6 @@
  * @package WooCommerce\Emails
  */

-use Automattic\WooCommerce\EmailEditor\Engine\Personalizer;
-
 if ( ! defined( 'ABSPATH' ) ) {
 	exit; // Exit if accessed directly.
 }
@@ -88,7 +86,7 @@ if ( ! class_exists( 'WC_Email_Customer_Partially_Refunded_Order', false ) ) :
 			 */
 			$subject = apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this );
 			if ( $this->block_email_editor_enabled ) {
-				$subject = $this->personalizer->personalize_transactional_content( $subject, $this, Personalizer::RENDERING_CONTEXT_TEXT );
+				$subject = $this->personalizer->personalize_transactional_rich_text_as_plain_text( $subject, $this );
 			}
 			return $subject;
 		}
diff --git a/plugins/woocommerce/includes/emails/class-wc-email-customer-pos-refunded-order.php b/plugins/woocommerce/includes/emails/class-wc-email-customer-pos-refunded-order.php
index 5bc8ebc68b1..9b27cb35b1a 100644
--- a/plugins/woocommerce/includes/emails/class-wc-email-customer-pos-refunded-order.php
+++ b/plugins/woocommerce/includes/emails/class-wc-email-customer-pos-refunded-order.php
@@ -132,7 +132,11 @@ if ( ! class_exists( 'WC_Email_Customer_POS_Refunded_Order', false ) ) :
 			 * @param WC_Email_Customer_POS_Refunded_Order $email Email object.
 			 * @since 3.7.0
 			 */
-			return apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this );
+			$subject = apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this );
+			if ( $this->block_email_editor_enabled ) {
+				$subject = $this->personalizer->personalize_transactional_rich_text_as_plain_text( $subject, $this );
+			}
+			return $subject;
 		}

 		/**
diff --git a/plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php b/plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php
index ae1b0763815..b8dfbeca72f 100644
--- a/plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php
+++ b/plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php
@@ -5,7 +5,6 @@
  * @package WooCommerce\Emails
  */

-use Automattic\WooCommerce\EmailEditor\Engine\Personalizer;
 use Automattic\WooCommerce\Utilities\FeaturesUtil;

 if ( ! defined( 'ABSPATH' ) ) {
@@ -128,7 +127,7 @@ if ( ! class_exists( 'WC_Email_Customer_Refunded_Order', false ) ) :
 			 */
 			$subject = apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this );
 			if ( $this->block_email_editor_enabled ) {
-				$subject = $this->personalizer->personalize_transactional_content( $subject, $this, Personalizer::RENDERING_CONTEXT_TEXT );
+				$subject = $this->personalizer->personalize_transactional_rich_text_as_plain_text( $subject, $this );
 			}
 			return $subject;
 		}
diff --git a/plugins/woocommerce/includes/emails/class-wc-email.php b/plugins/woocommerce/includes/emails/class-wc-email.php
index 11dfd990995..e285c73cc5b 100644
--- a/plugins/woocommerce/includes/emails/class-wc-email.php
+++ b/plugins/woocommerce/includes/emails/class-wc-email.php
@@ -5,7 +5,6 @@
  * @package WooCommerce\Emails
  */

-use Automattic\WooCommerce\EmailEditor\Engine\Personalizer;
 use Automattic\WooCommerce\EmailEditor\Engine\Renderer\Html2Text;
 use Automattic\WooCommerce\Internal\Email\EmailHeaders;
 use Automattic\WooCommerce\Internal\EmailEditor\BlockEmailRenderer;
@@ -595,8 +594,8 @@ class WC_Email extends WC_Settings_API {
 		 */
 		$subject = apply_filters( 'woocommerce_email_subject_' . $this->id, $this->format_string( $this->get_option_or_transient( 'subject', $this->get_default_subject() ) ), $this->object, $this );
 		if ( $this->block_email_editor_enabled ) {
-			// Because the new email editor uses rich-text component for subject editing, to be ensure that the subject is always in plain text, we need to strip all tags.
-			$subject = wp_strip_all_tags( $this->personalizer->personalize_transactional_content( $subject, $this, Personalizer::RENDERING_CONTEXT_TEXT ) );
+			// The block email editor edits the subject as rich text, so convert it to personalized plain text.
+			$subject = $this->personalizer->personalize_transactional_rich_text_as_plain_text( $subject, $this );
 		}
 		return $subject;
 	}
@@ -620,7 +619,7 @@ class WC_Email extends WC_Settings_API {
 		 */
 		$preheader = apply_filters( 'woocommerce_email_preheader' . $this->id, $this->format_string( $this->get_option_or_transient( 'preheader', '' ) ), $this->object, $this );
 		if ( $this->block_email_editor_enabled ) {
-			$preheader = $this->personalizer->personalize_transactional_content( $preheader, $this, Personalizer::RENDERING_CONTEXT_TEXT );
+			$preheader = $this->personalizer->personalize_transactional_rich_text_as_plain_text( $preheader, $this );
 		}
 		return $preheader;
 	}
diff --git a/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php b/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php
index 641be4c0974..eecfcc07ec7 100644
--- a/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php
+++ b/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php
@@ -135,8 +135,9 @@ class BlockEmailRenderer {
 			};
 			add_filter( 'woocommerce_email_editor_rendering_email_context', $filter_callback, 10, 1 );

-			$subject   = $wc_email->get_subject();
-			$preheader = $wc_email->get_preheader();
+			$subject = $wc_email->get_subject();
+			// The renderer takes the preheader as HTML, and get_preheader() returns plain text.
+			$preheader = htmlspecialchars( $wc_email->get_preheader(), ENT_QUOTES, 'UTF-8' );

 			if ( $email_post ) {
 				$rendered_email_data = $this->renderer->render( $email_post, $subject, $preheader, get_bloginfo( 'language' ) );
diff --git a/plugins/woocommerce/src/Internal/EmailEditor/TransactionalEmailPersonalizer.php b/plugins/woocommerce/src/Internal/EmailEditor/TransactionalEmailPersonalizer.php
index cade5f07047..5a883dad07d 100644
--- a/plugins/woocommerce/src/Internal/EmailEditor/TransactionalEmailPersonalizer.php
+++ b/plugins/woocommerce/src/Internal/EmailEditor/TransactionalEmailPersonalizer.php
@@ -46,6 +46,19 @@ class TransactionalEmailPersonalizer {
 		return $this->personalizer->personalize_content( $content, $rendering_context );
 	}

+	/**
+	 * Personalize rich text edited in the block email editor, such as the subject or preheader, as plain text.
+	 *
+	 * @since 11.4.0
+	 * @param string    $rich_text The rich text as stored by the editor.
+	 * @param \WC_Email $email     The WooCommerce email object.
+	 * @return string The personalized plain text.
+	 */
+	public function personalize_transactional_rich_text_as_plain_text( string $rich_text, \WC_Email $email ): string {
+		$this->configure_context_by_email( $email );
+		return $this->personalizer->personalize_rich_text_as_plain_text( $rich_text );
+	}
+
 	/**
 	 * Configure personalization context based on WooCommerce email object.
 	 *
diff --git a/plugins/woocommerce/tests/php/includes/emails/class-wc-email-test.php b/plugins/woocommerce/tests/php/includes/emails/class-wc-email-test.php
index 81570119c99..55975594c5f 100644
--- a/plugins/woocommerce/tests/php/includes/emails/class-wc-email-test.php
+++ b/plugins/woocommerce/tests/php/includes/emails/class-wc-email-test.php
@@ -1,6 +1,10 @@
 <?php
 declare( strict_types = 1 );

+use Automattic\WooCommerce\EmailEditor\Email_Editor_Container;
+use Automattic\WooCommerce\EmailEditor\Engine\PersonalizationTags\Personalization_Tag;
+use Automattic\WooCommerce\EmailEditor\Engine\Personalizer;
+use Automattic\WooCommerce\EmailEditor\Engine\PersonalizationTags\Personalization_Tags_Registry;
 use Automattic\WooCommerce\Internal\Features\FeaturesController;

 /**
@@ -39,6 +43,151 @@ class WC_Email_Test extends \WC_Unit_Test_Case {
 		parent::tearDown();
 	}

+	/**
+	 * @testdox With the block email editor, the subject keeps text after a "<" that does not start a tag and decodes entities.
+	 */
+	public function test_block_editor_subject_keeps_text_after_less_than_sign(): void {
+		$features_controller = wc_get_container()->get( FeaturesController::class );
+		$was_enabled         = $features_controller->feature_is_enabled( 'block_email_editor' );
+		$features_controller->change_feature_enable( 'block_email_editor', true );
+		$email  = new WC_Email_Customer_Processing_Order();
+		$filter = function () {
+			return '<strong>I <3 Shoes</strong> &amp; more';
+		};
+		add_filter( 'woocommerce_email_subject_' . $email->id, $filter );
+
+		try {
+			$this->assertSame( 'I <3 Shoes & more', $email->get_subject() );
+		} finally {
+			remove_filter( 'woocommerce_email_subject_' . $email->id, $filter );
+			$features_controller->change_feature_enable( 'block_email_editor', $was_enabled );
+		}
+	}
+
+	/**
+	 * @testdox With the block email editor, tag values in the subject and preheader are not parsed as HTML a second time.
+	 */
+	public function test_block_editor_subject_and_preheader_keep_literal_tag_text_from_values(): void {
+		$features_controller = wc_get_container()->get( FeaturesController::class );
+		$was_enabled         = $features_controller->feature_is_enabled( 'block_email_editor' );
+		$features_controller->change_feature_enable( 'block_email_editor', true );
+		$registry = Email_Editor_Container::container()->get( Personalization_Tags_Registry::class );
+		$registry->register(
+			new Personalization_Tag(
+				'Sale',
+				'[wc-email-test/sale]',
+				'Test',
+				function () {
+					return '&lt;em&gt;Sale&lt;/em&gt;';
+				}
+			)
+		);
+		$email  = new WC_Email_Customer_Processing_Order();
+		$filter = function () {
+			return '<strong>Big</strong> <!--[wc-email-test/sale]-->';
+		};
+		add_filter( 'woocommerce_email_subject_' . $email->id, $filter );
+		add_filter( 'woocommerce_email_preheader' . $email->id, $filter );
+
+		try {
+			$this->assertSame( 'Big <em>Sale</em>', $email->get_subject() );
+			$this->assertSame( 'Big <em>Sale</em>', $email->get_preheader() );
+
+			// The merchant's own text is not parsed as HTML again either, so a "<" in it can't hide a tag.
+			$filter_text = function () {
+				return '<strong>Big</strong> a&lt;b <!-- [wc-email-test/sale] -->';
+			};
+			add_filter( 'woocommerce_email_subject_' . $email->id, $filter_text, 20 );
+			add_filter( 'woocommerce_email_preheader' . $email->id, $filter_text, 20 );
+			$this->assertSame( 'Big a<b <em>Sale</em>', $email->get_subject() );
+			$this->assertSame( 'Big a<b <em>Sale</em>', $email->get_preheader() );
+			remove_filter( 'woocommerce_email_subject_' . $email->id, $filter_text, 20 );
+			remove_filter( 'woocommerce_email_preheader' . $email->id, $filter_text, 20 );
+		} finally {
+			remove_filter( 'woocommerce_email_subject_' . $email->id, $filter );
+			remove_filter( 'woocommerce_email_preheader' . $email->id, $filter );
+			$registry->unregister( '[wc-email-test/sale]' );
+			$features_controller->change_feature_enable( 'block_email_editor', $was_enabled );
+		}
+	}
+
+	/**
+	 * @testdox With the block email editor, getting a subject without tags still sets the personalization context the body uses.
+	 */
+	public function test_block_editor_subject_without_tags_sets_personalization_context(): void {
+		$features_controller = wc_get_container()->get( FeaturesController::class );
+		$was_enabled         = $features_controller->feature_is_enabled( 'block_email_editor' );
+		$features_controller->change_feature_enable( 'block_email_editor', true );
+		$personalizer = Email_Editor_Container::container()->get( Personalizer::class );
+		$personalizer->set_context( array() );
+		$order         = WC_Helper_Order::create_order();
+		$email         = new WC_Email_Customer_Processing_Order();
+		$email->object = $order;
+		$filter        = function () {
+			return 'Your order';
+		};
+		add_filter( 'woocommerce_email_subject_' . $email->id, $filter );
+
+		try {
+			$this->assertSame( 'Your order', $email->get_subject() );
+			$this->assertSame( $order, $personalizer->get_context()['order'] ?? null );
+		} finally {
+			remove_filter( 'woocommerce_email_subject_' . $email->id, $filter );
+			$personalizer->set_context( array() );
+			$features_controller->change_feature_enable( 'block_email_editor', $was_enabled );
+		}
+	}
+
+	/**
+	 * @testdox With the block email editor, emails that build their own subject also get it as plain text.
+	 */
+	public function test_block_editor_invoice_subject_is_plain_text(): void {
+		$features_controller = wc_get_container()->get( FeaturesController::class );
+		$was_enabled         = $features_controller->feature_is_enabled( 'block_email_editor' );
+		$features_controller->change_feature_enable( 'block_email_editor', true );
+		update_option( 'woocommerce_customer_invoice_settings', array( 'subject' => '<strong>Invoice</strong> a&lt;b' ) );
+		$email         = new WC_Email_Customer_Invoice();
+		$email->object = WC_Helper_Order::create_order();
+
+		try {
+			$this->assertSame( 'Invoice a<b', $email->get_subject() );
+		} finally {
+			delete_option( 'woocommerce_customer_invoice_settings' );
+			$features_controller->change_feature_enable( 'block_email_editor', $was_enabled );
+		}
+	}
+
+	/**
+	 * @testdox With the block email editor, the POS refunded order subject is filled in and converted to plain text.
+	 */
+	public function test_block_editor_pos_refunded_order_subject_is_plain_text(): void {
+		$features_controller = wc_get_container()->get( FeaturesController::class );
+		$was_enabled         = $features_controller->feature_is_enabled( 'block_email_editor' );
+		$features_controller->change_feature_enable( 'block_email_editor', true );
+		$registry = Email_Editor_Container::container()->get( Personalization_Tags_Registry::class );
+		$registry->register(
+			new Personalization_Tag(
+				'Store',
+				'[wc-email-test/store]',
+				'Test',
+				function () {
+					return 'Tom &amp; Jerry';
+				}
+			)
+		);
+		update_option( 'woocommerce_customer_pos_refunded_order_settings', array( 'subject_full' => '<strong>Refund</strong> a&lt;b from <!--[wc-email-test/store]-->' ) );
+		$email         = new WC_Email_Customer_POS_Refunded_Order();
+		$email->object = WC_Helper_Order::create_order();
+
+		try {
+			$this->assertSame( 'Refund a<b from Tom & Jerry', $email->get_subject() );
+		} finally {
+			delete_option( 'woocommerce_customer_pos_refunded_order_settings' );
+			$registry->unregister( '[wc-email-test/store]' );
+			$features_controller->change_feature_enable( 'block_email_editor', $was_enabled );
+		}
+	}
+
 	/**
 	 * @testdox Emails that do not support Cc/Bcc hide the fields and ignore stored or directly set values.
 	 */
diff --git a/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php b/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php
index 3006322a457..1f146ce63f9 100644
--- a/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php
@@ -128,6 +128,25 @@ class BlockEmailRendererTest extends \WC_Unit_Test_Case {
 		$this->assertStringContainsString( 'customer@test.com', $rendered_email );
 	}

+	/**
+	 * @testdox The plain-text preheader is passed to the renderer escaped, so tag-shaped text in it stays visible.
+	 */
+	public function testItEscapesThePlainTextPreheader(): void {
+		$this->skip_if_unsupported_environment();
+
+		$wc_mail_mock     = $this->createMock( \WC_Email::class );
+		$wc_mail_mock->id = 'test_email';
+		$wc_mail_mock->method( 'get_recipient' )->willReturn( 'customer@test.com' );
+		$wc_mail_mock->method( 'get_subject' )->willReturn( 'Test Woo Email' );
+		$wc_mail_mock->method( 'get_preheader' )->willReturn( 'Big <em>Sale</em> & more &lt;3' );
+		$wc_mail_mock->method( 'get_content_html' )->willReturn( 'Test Woo Content' );
+		$wc_mail_mock->method( 'get_block_editor_email_template_content' )->willReturn( 'Test Woo Content' );
+
+		$rendered_email = $this->block_email_renderer->maybe_render_block_email( $wc_mail_mock );
+
+		$this->assertStringContainsString( 'Big &lt;em&gt;Sale&lt;/em&gt; &amp; more &amp;lt;3', $rendered_email );
+	}
+
 	/**
 	 * @testdox Should render non-null HTML from the file template when no post mapping exists.
 	 */