twilio / twilio-python

A Python module for communicating with the Twilio API and generating TwiML.

Home Page:https://www.twilio.com/docs/libraries/python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UTF-8 content doesn't get properly serialized

igz-gp opened this issue · comments

Issue Summary

UTF-8 content doesn't get properly serialized

Steps to Reproduce

  1. Add any utf-8 content to a VoiceResponse. E.g. voice_response = VoiceResponse(); voice_response.say("An utf-8 character: ñ")
  2. Serialize the voice_response. E.g. str(voice_response)
  3. The result is '<?xml version="1.0" encoding="UTF-8"?><Response><Say>An utf-8 character: &#241;</Say></Response>'. The ñ character was html encoded.

Technical details:

  • twilio-python version: 7.15.0
  • python version: 3.9.15

Proposed solution:

Replace xml = ET.tostring(self.xml()).decode('utf-8')
with xml = ET.tostring(self.xml(), encoding='utf-8').decode('utf-8')
in

xml = ET.tostring(self.xml()).decode('utf-8')

I could make a PR if you want me to :)

Hi @igz-gp! Thanks for opening an issue! Please feel free to open a PR with a fix and our team will add it to our review backlog.