Issue with Tag in Titles Being Escaped
-
Summary
At some point, the
<br>
tag in titles created with the block editor started being output as text instead of creating a line break. The exact timing is unclear, but as of May 24, 2024, line breaks were working correctly. I was using the latest WordPress version at least since March.Detailed Situation- Posts created before this issue, which included
<br>
tags in titles, are recognized correctly as line breaks. Additionally, functions likestrip_tags()
infunctions.php
work as expected. - Although the exact trigger is unclear, the major change during this period was a WordPress version upgrade (plugins were also updated, but none related to titles or caching were used).
- I suspect that the block editor now escapes
<br>
tags when saving titles. - Checking the MySQL
wp_posts
table, titles that break correctly have<br>
saved, while those that don’t have<br>
saved.
Environment Information
- This issue only occurs on the client’s server and not on my Docker development environment.
- Both environments are running WordPress version 6.5.5.
- PHP versions are 8.1.25 on the server and 8.1.27 on Docker.
- MySQL versions are 5.7.12 on the server and 5.7.38 on Docker.
- MySQL character encoding for
post_title
isutf8mb4_general_ci
on both environments.
Request
I am seeking solutions or information from anyone who has encountered a similar issue. Any guidance or advice would be greatly appreciated.
日本語版
日本語話者なので、日本語も掲載します。
概要
ある時点以降、ブロックエディタでタイトルに
<br>
を記載しても改行されず、文字として出力されるようになりました。この現象の発生時点は不明ですが、2024年5月24日時点では問題なく改行されていました。少なくとも3月時点では最新のWordPressを使用していました。状況の詳細- 以前に投稿されたタイトルに
<br>
が含まれている投稿は、改行タグとして正しく認識されています。また、functions.phpでstrip_tags()などの関数も有効に働いています。 - 明確な発生時期はわからないものの、WordPressのバージョンアップを行ったことが唯一の大きな変更点です(プラグインも更新しましたが、タイトルに関わるものやキャッシュ系のプラグインは使用していません)。
- このことから、ブロックエディタでタイトルを保存する際に
<br>
タグがエスケープされるようになったのではないかと考えています。 - 実際にMySQLの
wp_posts
テーブルを確認すると、問題なく改行されるタイトルは<br>
として保存されていますが、改行されないものは<br>
とエスケープされて保存されています。
環境情報
- この現象はクライアントのサーバでのみ発生し、自分のDockerによる開発環境では発生しません。
- WordPressのバージョンは両環境ともに6.5.5です。
- PHPのバージョンは、サーバが8.1.25、Dockerが8.1.27です。
- MySQLのバージョンは、サーバが5.7.12、Dockerが5.7.38です。
- MySQLの文字エンコードはサーバもDockerも
utf8mb4_general_ci
です。
お願い
この問題について解決策や同様の事象に遭遇した方の情報を求めています。何かご存知の方がいらっしゃいましたら、ご教示いただけると幸いです。
- Posts created before this issue, which included
- The topic ‘Issue with Tag in Titles Being Escaped’ is closed to new replies.