WordPress / WordPress/wordpress-importer
Post content didn't import properly due to parsing issue in get_tag
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 89
- Forks
- 96
- Avg merge
- 1h 13m
- Merged PRs (30d)
- 2
Description
Exported XML via wordpress 5.1 could not be properly imported.
The imported content will always have ]> at end of post.
The xml is like:
<content:encoded>
\t\t<![CDATA[some stuff]]>
\t\t</content:encoded>
This is valid XML, but it will cause issue in current parsing logic:
https://github.com/WordPress/wordpress-importer/blob/64e575ac5e0c91225dc2a4661c8208197f7dc5c1/src/parsers/class-wxr-parser-regex.php#L115-L118
'<![CDATA[' is not the heading content, here we need to 'trim' content inside the tag first.
A quick fix is to add \s* around (.*?) in preg_match.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/parsers/class-wxr-parser-regex.php around lines 115-118, where the content:encoded value is matched. Check the regex against the whitespace-wrapped CDATA example from WordPress 5.1; done means imported posts no longer retain the trailing ]> while valid XML content remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100