1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-04 10:36:17 +01:00

Catch non-utf8 and convert it to utf8 inside create_submit_request() to prevent

osc submit -m 'latin-1 chars' from exploding.
Not sure why 'osc commit' or 'osc vc' work with latin-1 chars in their messages.
This commit is contained in:
Juergen Weigert 2011-03-03 18:27:12 +01:00
parent b618d16f62
commit 518229067c

View File

@ -3467,6 +3467,16 @@ def create_submit_request(apiurl,
message=None, orev=None, src_update=None):
import cgi
try:
unicode(message).decode('utf-8')
except:
# UnicodeDecodeError: 'utf8' codec can't decode bytes in position 365-367: invalid data
# If it was not valid utf-8, we assume it was some latin-X, which needs to be
# encoded in utf-8, before it goes into XML.
# FIXME: Should this be handled earlier? Are there more places?
message = unicode(message).encode('utf-8')
options_block=""
if src_update:
options_block="""<options><sourceupdate>%s</sourceupdate></options> """ % (src_update)