-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
project_loader: handle invalid unicode chars #1941
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
006fac3
project_loader: handle invalid unicode chars
e34e265
Test with an actually invalid special character
3d4a4b2
Employ work-around for invalid unicode
d9a8b7d
Merge branch 'master' into yaml-invalid-unicode
af4bf8e
Patch pyyaml as part of the Snapcraft snap build
d04946c
Move invalid unicode test to integration tests
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
diff --git a/yaml/emitter.py b/yaml/emitter.py | ||
index 34cb145..1f8ed92 100644 | ||
--- a/yaml/emitter.py | ||
+++ b/yaml/emitter.py | ||
@@ -698,7 +698,8 @@ class Emitter: | ||
line_breaks = True | ||
if not (ch == '\n' or '\x20' <= ch <= '\x7E'): | ||
if (ch == '\x85' or '\xA0' <= ch <= '\uD7FF' | ||
- or '\uE000' <= ch <= '\uFFFD') and ch != '\uFEFF': | ||
+ or '\uE000' <= ch <= '\uFFFD' | ||
+ or '\U00010000' <= ch < '\U0010ffff') and ch != '\uFEFF': | ||
unicode_characters = True | ||
if not self.allow_unicode: | ||
special_characters = True | ||
diff --git a/yaml/reader.py b/yaml/reader.py | ||
index f70e920..5764f2d 100644 | ||
--- a/yaml/reader.py | ||
+++ b/yaml/reader.py | ||
@@ -134,7 +134,7 @@ class Reader(object): | ||
self.encoding = 'utf-8' | ||
self.update(1) | ||
|
||
- NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]') | ||
+ NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]') | ||
def check_printable(self, data): | ||
match = self.NON_PRINTABLE.search(data) | ||
if match: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright (C) 2018 Canonical Ltd | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
import os | ||
|
||
import testscenarios | ||
|
||
from tests import integration, fixture_setup | ||
|
||
|
||
class UnicodePropertyTestCase(testscenarios.WithScenarios, | ||
integration.TestCase): | ||
|
||
scenarios = [ | ||
('summary', | ||
dict(name='foo', summary='bar💩', description='baz')), | ||
('description', | ||
dict(name='foo', summary='bar', description='baz💩')), | ||
] | ||
|
||
def test_invalid_unicode_workaround(self): | ||
if not (os.getenv('SNAPCRAFT_FROM_SNAP', False) or | ||
os.getenv('SNAPCRAFT_FROM_DEB', False)): | ||
self.skipTest('The yaml unicode patch is applied to the snap ' | ||
'and python3-yaml package, but not PyYAML in PyPI') | ||
|
||
snapcraft_yaml = fixture_setup.SnapcraftYaml( | ||
self.path, name=self.name, | ||
summary=self.summary, description=self.description) | ||
snapcraft_yaml.update_part('my-part', { | ||
'plugin': 'nil', | ||
}) | ||
self.useFixture(snapcraft_yaml) | ||
self.run_snapcraft('pull') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to add
patches
to after here. It has python which haspatches
in ITS after... but that will break if it ever changes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the after for python includes this, so the chain is somewhat complete; I will sort of ignore this as we are going back to
stage-packages
as soon as our SRUed deb gets in with the fixes for classicThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch otherwise ;-)