Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array2XML is not handling invalid characters in node values #17

Closed
JanisE opened this issue Apr 6, 2021 · 2 comments
Closed

Array2XML is not handling invalid characters in node values #17

JanisE opened this issue Apr 6, 2021 · 2 comments
Labels

Comments

@JanisE
Copy link
Contributor

JanisE commented Apr 6, 2021

If you do this:

print_r(\LaLit\XML2Array::createArray(\LaLit\Array2XML::createXML('myxml', ['ttt' => 'oo� o'])->saveXML()));

you'll get a PHP fatal error "Error parsing the XML string" even though the XML string is prepared by \LaLit\Array2XML itself.

The reason is that a PHP string may contain characters that are invalid in XML, see https://www.w3.org/TR/xml/#NT-Char
For example, characters x00-x09 are invalid, x02 is being used in the code example above.

Getting such characters into data is easy enough, e.g., it may happen when copying content from a PDF viewer.

Seeing how there already is exception [Array2XML] Illegal character in attribute name. possible, there should also be an exception for illegal characters in node values.

@JanisE JanisE changed the title Array2XML is not handling invalid characters Array2XML is not handling invalid characters in node values Apr 6, 2021
@rquadling
Copy link
Member

Thanks for this. Apologies for the delay in handling this.

@rquadling rquadling added the bug label Jun 29, 2021
rquadling pushed a commit that referenced this issue Mar 8, 2024
- Removed Scrutinzer, Stickler, and TravisCI configurations.
- Allow any/all versions for testing, remove Mockery (as it is unused) and introduce a Diff check for the more complex
  comparisons with running unit tests.
- Add parameter type hints up to PHP 7.0 standards.
- Stop warnings about null being used as a value.
- Replace invalid XML document warnings with an exception.
- Add support for namespaces in root node (Thank you blagi [#20](#20)).
- Throw `Exception` for invalid characters when using `Array2XML::createXML()` for normal values, `@value`, and `cdata`
  values (Thank you Jānis Elmeris [#17](#17)).
- Introduce GitHub workflow, testing the library on all versions from PHP 7.0 to 8.3

### Significant upgrades to unit test files:
- Introduce a proxy for PHPUnit's deprecation of `expectExceptionMessageRegExp($messageRegExp)`.
- Partially fix the PHPUnit `phpunit.xml` configuration file.
- Use the new proxy for all tests.
- Replace the deprecated docblock entries for `@exceptedException` / `@expectedExceptionMessage` with their equivalent
  method calls `$this->expectedException()` / `$this->exceptedExceptionMessage()`.
- Fix all data providers that have keys for the value in the datasets to match the parameter names of the test method.
  The use of named parameters was introduced in PHP 8.0.
- Introduce the new attributes mechanism for data providers. This does NOT conflict with the older `@dataProvider`
  docblock annotation.
@rquadling
Copy link
Member

Hopefully all fixed in v3.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants