Skip to content

Commit

Permalink
wmllint: Leave gzipped binary files alone, they're not safe for consu…
Browse files Browse the repository at this point in the history
…mption

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 c92e167)
  • Loading branch information
irydacea committed Oct 7, 2018
1 parent 81bd61a commit fb409b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions data/tools/wesnoth/wmltools3.py
Expand Up @@ -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:
Expand Down

0 comments on commit fb409b5

Please sign in to comment.