[wp-trac] [WordPress Trac] #59608: [bug] insert_with_markers with a UTF-8 translated marker causing .htaccess file broken with garbled characters
WordPress Trac
noreply at wordpress.org
Thu Jan 18 12:24:11 UTC 2024
#59608: [bug] insert_with_markers with a UTF-8 translated marker causing .htaccess
file broken with garbled characters
--------------------------+------------------------------
Reporter: sammyhk | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version: 6.3.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by hh3):
I also am having this issue with version 6.4.2 in `Chinese (Taiwan)`. The
problem is strange in that only some characters causes the problem. I have
tried manually inserting the Chinese character into the misc.php code.
Changing this code:
{{{
$instructions = sprintf(
__(
'The directives (lines) between "BEGIN %1$s" and "END %1$s" are
dynamically generated, and should only be modified via WordPress filters.
Any changes to the directives between these markers will be overwritten.'
),
$marker
);
}}}
to this would break the htaccess
{{{
$instructions = '# 兩';
}}}
but to this would not
{{{
$instructions = '# 我';
}}}
my php.ini `default_charset = "UTF-8"`, both input_encoding and
output_encoding are not set.
Another test case I tried was to manually insert `# 兩` somewhere else in
the .htaccess. This also causes the problem after insert_with_markers is
executed. After reading through the code, it seems the code is reading and
re-writing the entire file. This seem to indicate to me that the problem
occurs when the strings are re-written into .htaccess.
Forcing the code to do `mb_convert_encoding($line, 'UTF-8')` on every
single line also doesn't seem to work as suggested on multiple posts on
StackExchange.
I have tried to also force the code to write the UTF-8 BOM at the
beginning of the file, but Apache also fail with http 500 upon reading the
BOM.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59608#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list