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.
The current version of the Twilio PHP library will take input passed in and run it through the PHP
htmlentities
function. This produces "named" character entities in the output. Named character entities and XML don't get along. Only the 'quot', 'amp', 'apos', 'lt', and 'gt' entities are defined.This change replaces the
htmlentities
call with an process that decodes the input and then runs it throughhtmlspecialchars
to produce "numeric" entities instead.This should accommodate most western character sets. Non standard (to htmlspecialchars) multi-byte character sets will fail silently in Twilio (ie: say nothing) instead of throwing an application error.
Desired text
Old and busted
Twilio returns "An application error has occurred" with the actual logged error being "Error on line 2 of document : The entity "Atilde" was referenced, but not declared. Please ensure that the response body is a valid XML document."
New Hotness
Twilio properly pronounces the characters.
Test
The unit tests have been updated to test for desired output, but here's a quick test that can be run to observe the output:
New Requirements
Library now requires PHP 5.2.3 (formerly 5.2.1) to support the non-double encoding flag on the php function
htmlspecialchars