Skip to content

Commit

Permalink
Don't analyze invalid tags on IBPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Reflejo committed Nov 24, 2015
1 parent 377e094 commit 571df81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ibunfuck.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ def __init__(self, path):
def _clear_patch(self, patch, processors):
has_changes = False
for i, patch_piece in enumerate(patch):
length = len(patch_piece)
for j, hunk in enumerate(patch_piece[::-1]):
if not all(p(hunk) for p in processors):
continue

del patch[i][len(patch_piece) - j - 1]
del patch[i][length - j - 1]

has_changes = has_changes or len(patch[i]) > 0

Expand Down
6 changes: 6 additions & 0 deletions src/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ def _xml_changes(klass, chunk):
@classmethod
def _is_valid_dimension(klass, hunk, tag, properties):
minus, plus = klass._xml_changes(hunk)
if any(x.tag != tag for x in minus + plus):
return True

if len(minus) == 1 and len(plus) == 1:
mnode, pnode = minus[0], plus[0]
if mnode.tag != pnode.tag or mnode.tag != tag or pnode.tag != tag:
return True

is_right_tag = mnode.tag == pnode.tag == tag
diffs = [abs(float(mnode.attrib[p]) - float(pnode.attrib[p]))
for p in properties]
Expand Down

0 comments on commit 571df81

Please sign in to comment.