[Commits] [wesnoth/wesnoth] 86b065: wmliterator: fix unterminated loop in lua-strip

GitHub noreply at github.com
Mon May 11 06:40:01 UTC 2015


  Branch: refs/heads/1.12
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 86b065fd795666aff4d4e4a3b3a7169b42a8cfbd
      https://github.com/wesnoth/wesnoth/commit/86b065fd795666aff4d4e4a3b3a7169b42a8cfbd
  Author: Groggy Dice <groggydice at yahoo.com>
  Date:   2015-05-11 (Mon, 11 May 2015)

  Changed paths:
    M data/tools/wesnoth/wmliterator.py

  Log Message:
  -----------
  wmliterator: fix unterminated loop in lua-strip

An old add-on triggered a wmliterator crash with this comment:

    #>>>> !!!!! REMOVE THIS AFTER TEST !!!!! <<<<#

The traceback showed that the crash came from the lua-stripping
code, which interprets "<<" as the start of a lua string. But below
it is code to remove quoted strings, and it doesn't crash, even
though there are cases where authors forgot to close a quote.

Two key differences stood out in the otherwise similar second
code: only looking for the endquote string in the text after
beginquote, and testing that endquote was less than 0, not -1.

Changing both gets the loop to terminate. Making it search the
text only after "beginquote+2" means that ">>" will no longer
be found, giving endquote a value of -1. But -1 is not less than
-1, so that must be changed to " < 0" to close the loop.





More information about the Commits mailing list