Repository navigation
Conversation
parseXmlLanguageFile() loaded metadata files from language packs with plain simplexml_load_file(): malformed XML emitted a series of libxml warnings, and a metafile without a <metadata> element made the foreach over null warn as well. libxml errors are now collected internally and cleared, LIBXML_NONET forbids network access while parsing, and a file without <metadata> is treated as not being a metadata file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary of Changes
LanguageHelper::parseXmlLanguageFile()loaded the metadata file of a language pack with a plainsimplexml_load_file(). Reproduced: a malformed file emits a series of libxml warnings, and a well-formed<metafile>without a<metadata>child makes theforeachovernullwarn as well ("foreach() argument must be of type array|object").The method now collects libxml errors internally (restoring the previous
libxml_use_internal_errors()setting and clearing the errors afterwards), passesLIBXML_NONETso parsing never touches the network, and returnsnullfor a file without<metadata>. Before, that case returned an empty array, whichgetMetadata()andparseLanguageFiles()already treated likenull. External entities are not expanded by libxml ≥ 2.9 anyway, so this is hardening rather than an XXE fix.Testing Instructions
New
tests/MetadataXmlTest.phpwith the fixturestests/data/metadata/broken.xmlandno-metadata.xml(new files, so they do not conflict with #59): both returnnullwithout warnings, the libxml state is restored, and a valid file is still read. The two malformed-file tests fail without the change insrc/LanguageHelper.php; the whole suite passes with it (php vendor/bin/phpunit).Documentation Changes Required
docs/overview.md: a new paragraph at the end of "Things to know before you build on this" on malformed metadata files.🤖 Generated with Claude Code