mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 04:48:39 +00:00
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 c92e167a14229ed0d9b6f16f1d1ca31cacd292cd)
This commit is contained in:
parent
81bd61ae14
commit
fb409b5db4
@ -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…
x
Reference in New Issue
Block a user