diff --git a/src/Voice/Bxml/Response.php b/src/Voice/Bxml/Response.php
index ed24d75..35ede23 100644
--- a/src/Voice/Bxml/Response.php
+++ b/src/Voice/Bxml/Response.php
@@ -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);
}
diff --git a/tests/BxmlTest.php b/tests/BxmlTest.php
index c1f0e49..0e5f301 100644
--- a/tests/BxmlTest.php
+++ b/tests/BxmlTest.php
@@ -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 = 'These characters cause problems < > &';
+ $responseXml = $response->toBxml();
+ $this->assertEquals($expectedXml, $responseXml);
+ }
+
public function testSpeakSentenceSSML() {
$speakSentence = new BandwidthLib\Voice\Bxml\SpeakSentence('Hello, you have reached the home of Antonio Mendoza.Please leave a message.');
$response = new BandwidthLib\Voice\Bxml\Response();