Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Voice/Bxml/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public function __construct() {
* @param Verb $verb The verb to add to the list
*/
public function addVerb($verb) {
foreach($verb as $key => $value) { // encodes any verb attributes of type string to avoid php character encoding bug
if(gettype($value) == "string") {
$verb->$key = htmlspecialchars($value, ENT_XML1, 'UTF-8');
}
}
array_push($this->verbs, $verb);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/BxmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ public function testSpeakSentence() {
$this->assertEquals($expectedXml, $responseXml);
}

public function testSpeakSentenceEncode() {
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence("These characters cause problems < > &");
$speakSentence->voice("susan");
$speakSentence->locale("en_US");
$speakSentence->gender("female");
$response = new BandwidthLib\Voice\Bxml\Response();
$response->addVerb($speakSentence);
$expectedXml = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence locale="en_US" gender="female" voice="susan">These characters cause problems &lt; &gt; &amp;</SpeakSentence></Response>';
$responseXml = $response->toBxml();
$this->assertEquals($expectedXml, $responseXml);
}

public function testSpeakSentenceSSML() {
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence('Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.');
$response = new BandwidthLib\Voice\Bxml\Response();
Expand Down