wmllint: Leave gzipped binary files alone, they're not safe for consumption
Fixes wmllint crashing like this upon encountering a gzip tarball in an
add-on:
Traceback (most recent call last):
File "/home/shadowm/bin/wmllint-1.14", line 3188, in <module>
for fn in allcfgfiles(directory):
File "/home/shadowm/bin/wmllint-1.14", line 2944, in allcfgfiles
if interesting(os.path.join(root, name)):
File "/home/shadowm/bin/wmllint-1.14", line 2927, in interesting
return fn.endswith(".cfg") or is_map(fn) or issave(fn)
File "/home/shadowm/src/wesnoth-1.14/data/tools/wesnoth/wmltools3.py", line 270, in issave
return firstline.startswith("label=")
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
[ci skip]
(cherry-picked from commit c92e167a14
)
This commit is contained in:
parent
81bd61ae14
commit
fb409b5db4
2 changed files with 4 additions and 0 deletions
|
@ -82,6 +82,7 @@
|
|||
selection dialog is dismissed.
|
||||
* Fixed an issue with positioned sound sources ignoring the volume set in
|
||||
Preferences after going off the audible radius and back (issue #3280).
|
||||
* Fixed wmllint choking on gzipped binary files (e.g. gzipped tarballs).
|
||||
|
||||
## Version 1.14.3
|
||||
### AI
|
||||
|
|
|
@ -260,6 +260,9 @@ def issave(filename):
|
|||
if filename.endswith(".gz"):
|
||||
with gzip.open(filename) as content:
|
||||
firstline = content.readline()
|
||||
if not isinstance(firstline, str):
|
||||
# It's a compressed binary file
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
with codecs.open(filename, "r", "utf8") as content:
|
||||
|
|
Loading…
Add table
Reference in a new issue