Repository navigation
fix(VAPI-4457): scope SSML un-escape to SpeakSentence text - #321
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
I think we can remove this import here too
| @@ -47,4 +46,4 @@ def _attributes(self): | |||
|
|
|||
| def to_bxml(self) -> str: | |||
There was a problem hiding this comment.
this is now the exact same as to_bxml in Verb, so I don't think we need the override anymore. Definitely double check behind me but I think this can go away
| _SSML_REGEX = re.compile(r"<([a-zA-Z//].*?)>") | ||
|
|
||
|
|
||
| def unescape_ssml(bxml: str) -> str: |
There was a problem hiding this comment.
can we make this _unescape_ssml so its private? I don't think customers should ever need to access it
| response.add_verb(self.speak_sentence) | ||
| assert expected == response.to_bxml() | ||
|
|
||
| def test_ssml_unescaped_but_other_attributes_untouched(self): |
There was a problem hiding this comment.
I think both of these tests can be moved to test_response.py, and can we update the assertions to match an entire string like the rest of the tests? Just to be more strict.
| )) | ||
| assert expected_bxml == self.response.to_bxml() | ||
|
|
||
| def test_empty_speak_sentence_does_not_swallow_following_verbs(self): |
There was a problem hiding this comment.
nitpick but can we give this a docstring to match the others
| def test_ssml_unescaped_but_other_attributes_untouched(self): | ||
| """SSML in <SpeakSentence> text is un-escaped; escaped characters in other elements' attributes are not | ||
| """ | ||
| expected_bxml = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<Response><Redirect redirectUrl="https://example.com/a?info=<https://example.com/c.pem>" /><SpeakSentence voice="julie" gender="female" locale="en_US">Hello. Your number is <say-as interpret-as="telephone">asdf</say-as>, lets play a game.</SpeakSentence></Response>' |
There was a problem hiding this comment.
another nitpick but can we make this a double quote string instead of escaping the single quotes, to match the other strings
Summary
The SSML un-escape (
<tag>-><tag>) ran over the whole serialized BXML, so it also rewrote escaped<...>inside XML attribute values into a raw<...>. A raw<is illegal in an attribute value, so the output was malformed XML and the API returnedinvalid_bxml.The un-escape now only applies to the text inside
<SpeakSentence>...</SpeakSentence>, matching the C# and Ruby SDKs. Attribute values and every other element keep their XML escaping.Jira: VAPI-4457
Validation
mainand pass on this branch.