humanmade / humanmade/hm-content-import
Non UTF-8 reported encoding trips up SimpleXML
- Dominant language
- PHP
- Stars
- 30
- Forks
- 7
- Avg merge
- 6h 39m
- Merged PRs (30d)
- 2
Description
The XML files from IM report that they use `UTF-16` encoding despite actually being encoded as `UTF-8`. This trips up `simplexml_load_string()` in the `XML_Files::parse_item()` method.
For this particular migration, I've overrwritten the `Files::get_file_contents()` method in the importer class and performed a string replacement:
```php
$contents = str_replace( 'encoding="utf-16"', 'encoding="utf-8"', $contents );
```
HMCI should include a verification that UTF-8 is in use in the imported XML file.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with XML_Files::parse_item() and trace how it passes imported contents to simplexml_load_string(). Review the existing Files::get_file_contents() workaround as context, then verify handling for XML that declares UTF-16 while containing UTF-8 data; done means this input no longer trips the parser.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100