From 571df8123f0f50238305a8939f5b21a3888d22d3 Mon Sep 17 00:00:00 2001 From: Martin Conte Mac Donell Date: Tue, 24 Nov 2015 12:44:17 -0800 Subject: [PATCH] Don't analyze invalid tags on IBPlugin --- src/ibunfuck.py | 3 ++- src/plugins.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ibunfuck.py b/src/ibunfuck.py index e1ea7fd..5cbf651 100644 --- a/src/ibunfuck.py +++ b/src/ibunfuck.py @@ -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 diff --git a/src/plugins.py b/src/plugins.py index 0f039f2..f94c26f 100644 --- a/src/plugins.py +++ b/src/plugins.py @@ -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]