[ 
https://issues.apache.org/jira/browse/THRIFT-4207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16663061#comment-16663061
 ] 

ASF GitHub Bot commented on THRIFT-4207:
----------------------------------------

jeking3 commented on a change in pull request #1274: THRIFT-4207: Make sure 
Python Accelerated protocol does not allow invalid UTF-8
URL: https://github.com/apache/thrift/pull/1274#discussion_r228004916
 
 

 ##########
 File path: lib/py/src/protocol/TProtocol.py
 ##########
 @@ -118,6 +118,8 @@ def writeDouble(self, dub):
         pass
 
     def writeString(self, str_val):
+        if isinstance(str_val, bytes):
+            str_val = str_val.decode('utf8')
 
 Review comment:
   Can `six` help here?  `six.binary_type` for example.  Or check for python 
version and use `bytearray` for py2 and bytes for py3?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Accelerated version of TBinaryProtocol allows invalid input to string fields.
> -----------------------------------------------------------------------------
>
>                 Key: THRIFT-4207
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4207
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.10.0
>            Reporter: Elvis Pranskevichus
>            Assignee: Aki Sukegawa
>            Priority: Major
>
> {{TBinaryProtocolAccelerated}} and {{TCompactProtocolAccelerated}} currently 
> accept arbitrary bytes as input to string fields even when {{py:utf8strings}} 
> is on.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to