Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add semicolon to style data for safety #62

Merged
merged 1 commit into from

2 participants

adhiraj Aaron Swartz
adhiraj

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.

adhiraj adhiraj 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.
65a540b
Aaron Swartz
Owner

Been getting a ton of pull requests lately. Is there some reason everyone is using this now?

Aaron Swartz
Owner

Can you add a test case for this?

Aaron Swartz aaronsw merged commit c654527 into from
adhiraj adhiraj referenced this pull request from a commit in adhiraj/html2text
adhiraj adhiraj Added testcase for pull request #62: @import css statements not termi…
…nated by ; should be handled correctly
0d41bc9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. adhiraj

    Add semicolon to style data for safety

    adhiraj authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  html2text.py
1  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:]
Something went wrong with that request. Please try again.