Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
d9da8a43
Commit
d9da8a43
authored
Feb 17, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of unicode in XML in Python 2
Fixes #996 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
05d3a102
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
weblate/trans/checks/markup.py
weblate/trans/checks/markup.py
+10
-2
weblate/trans/tests/test_markup_checks.py
weblate/trans/tests/test_markup_checks.py
+4
-0
No files found.
weblate/trans/checks/markup.py
View file @
d9da8a43
...
...
@@ -25,6 +25,8 @@ import re
from
django.utils.translation
import
ugettext_lazy
as
_
import
six
from
weblate.trans.checks.base
import
TargetCheck
BBCODE_MATCH
=
re
.
compile
(
...
...
@@ -95,8 +97,14 @@ class XMLTagsCheck(TargetCheck):
'''
Wrapper for parsing XML.
'''
text
=
strip_entities
(
text
)
return
cElementTree
.
fromstring
(
'<weblate>%s</weblate>'
%
text
)
text
=
''
.
join
(
(
'<weblate>'
,
strip_entities
(
text
),
'</weblate>'
)
)
if
six
.
PY2
:
text
=
text
.
encode
(
'utf-8'
)
return
cElementTree
.
fromstring
(
text
)
def
check_single
(
self
,
source
,
target
,
unit
):
# Quick check if source looks like XML
...
...
weblate/trans/tests/test_markup_checks.py
View file @
d9da8a43
...
...
@@ -22,6 +22,7 @@
Tests for quality checks.
"""
from
__future__
import
unicode_literals
from
weblate.trans.checks.markup
import
(
BBCodeCheck
,
XMLTagsCheck
,
...
...
@@ -63,3 +64,6 @@ class XMLTagsCheckTest(CheckTestCase):
(
24
,
28
,
'</b>'
),
]
)
def
test_unicode
(
self
):
self
.
do_test
(
False
,
(
'<a>zkouška</a>'
,
'<a>zkouška</a>'
,
''
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment