Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
installsystems
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Seblu
installsystems
Commits
bc5f6ff6
Commit
bc5f6ff6
authored
12 years ago
by
Sébastien Luttringer
Browse files
Options
Downloads
Patches
Plain Diff
tarball interface encode check encoding is in UTF8
parent
410ee846
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
installsystems/image.py
+4
-4
4 additions, 4 deletions
installsystems/image.py
installsystems/tarball.py
+12
-0
12 additions, 0 deletions
installsystems/tarball.py
with
16 additions
and
4 deletions
installsystems/image.py
+
4
−
4
View file @
bc5f6ff6
...
...
@@ -651,7 +651,7 @@ class PackageImage(Image):
'''
desc
=
{}
# check format
img_format
=
self
.
_tarball
.
get_
str
(
"
format
"
)
img_format
=
self
.
_tarball
.
get_
utf8
(
"
format
"
)
try
:
if
float
(
img_format
)
>=
math
.
floor
(
float
(
self
.
format
))
+
1.0
:
raise
Exception
()
...
...
@@ -660,7 +660,7 @@ class PackageImage(Image):
desc
[
"
format
"
]
=
img_format
# check description
try
:
img_desc
=
self
.
_tarball
.
get_
str
(
"
description.json
"
)
img_desc
=
self
.
_tarball
.
get_
utf8
(
"
description.json
"
)
desc
.
update
(
json
.
loads
(
img_desc
))
self
.
check_image_name
(
desc
[
"
name
"
])
self
.
check_image_version
(
desc
[
"
version
"
])
...
...
@@ -674,7 +674,7 @@ class PackageImage(Image):
raise
Exception
(
u
"
Invalid description: %s
"
%
e
)
# try to load changelog
try
:
img_changelog
=
self
.
_tarball
.
get_
str
(
"
changelog
"
)
img_changelog
=
self
.
_tarball
.
get_
utf8
(
"
changelog
"
)
desc
[
"
changelog
"
]
=
Changelog
(
img_changelog
)
except
KeyError
:
desc
[
"
changelog
"
]
=
Changelog
(
""
)
...
...
@@ -747,7 +747,7 @@ class PackageImage(Image):
warn
(
u
"
No file matching %s
"
%
filename
)
for
filename
in
filelist
:
arrow
(
filename
)
out
(
self
.
_tarball
.
get_
str
(
filename
))
out
(
self
.
_tarball
.
get_
utf8
(
filename
))
def
download
(
self
,
directory
,
force
=
False
,
image
=
True
,
payload
=
False
):
'''
...
...
This diff is collapsed.
Click to expand it.
installsystems/tarball.py
+
12
−
0
View file @
bc5f6ff6
...
...
@@ -25,6 +25,9 @@ class Tarball(tarfile.TarFile):
ti
.
mtime
=
int
(
time
.
time
())
ti
.
uid
=
ti
.
gid
=
0
ti
.
uname
=
ti
.
gname
=
"
root
"
# unicode char is encoded in UTF-8, has changelog must be in UTF-8
if
isinstance
(
content
,
unicode
):
content
=
content
.
encode
(
"
UTF-8
"
)
ti
.
size
=
len
(
content
)
if
content
is
not
None
else
0
self
.
addfile
(
ti
,
StringIO
.
StringIO
(
content
))
...
...
@@ -36,6 +39,15 @@ class Tarball(tarfile.TarFile):
fd
=
self
.
extractfile
(
ti
)
return
fd
.
read
()
if
fd
is
not
None
else
""
def
get_utf8
(
self
,
name
):
'''
Return an unicode string from a file encoded in UTF-8 inside tarball
'''
try
:
return
unicode
(
self
.
get_str
(
name
),
"
UTF-8
"
)
except
UnicodeDecodeError
:
raise
Exception
(
u
"
Invalid UTF-8 character in %s
"
%
name
)
def
getnames
(
self
,
re_pattern
=
None
,
glob_pattern
=
None
,
dir
=
True
):
names
=
super
(
Tarball
,
self
).
getnames
()
# regexp matching
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment