Permalink
Browse files

Add semicolon to style data for safety

If the style data does not contain a semicolon, the loop removing @import
statements will run infinitely, because the search for ';' returns -1, which
with a +1 becomes 0, and appends the data variable to itself. Making sure the
data variable has at least one semicolon fixes this problem.
  • Loading branch information...
1 parent 0fbc6af commit 65a540bebd13c274ace5d6d013ec8a9ede132908 @adhiraj adhiraj committed Nov 16, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 html2text.py
View
@@ -110,6 +110,7 @@ def dumb_property_dict(style):
def dumb_css_parser(data):
"""returns a hash of css selectors, each of which contains a hash of css attributes"""
# remove @import sentences
+ data += ';'
importIndex = data.find('@import')
while importIndex != -1:
data = data[0:importIndex] + data[data.find(';', importIndex) + 1:]

0 comments on commit 65a540b

Please sign in to comment.