Fix character decoding regression when title precedes meta[charset]
#106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix character decoding regression when
titleprecedesmeta[charset]Because of PHP 8.2 deprecation, in f14428e, we stopped converting non-ASCII characters to HTML entities. Instead, we started to explicitly insert
meta[charset]tag at the start of the document.Later, we discovered that was breaking
html[lang]so, in efbbc86, we made the insertion smarter. One of the improvements was that it would not insert themeta[charset]tag when it was already present.That, however, broke websites that had
titletag beforemeta[charset]. On those, libxml2 would decode thetitlecontents as ISO-8859-1.We could improve the logic (e.g. check that there is not text content before
meta[charset]) or insert the tag unconditionally but it will probably be simplest to just go back to converting the non-ASCII characters to entities, just using non-deprecated function variant.Fixes: wallabag/wallabag#8158