From 420a428b6e59afd5e5743c8ac9b19a281410e9f1 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 14 Nov 2008 21:57:14 +0000 Subject: =?UTF-8?q?Make=20the=20EbuildQuote=20check=20filter=20out=20match?= =?UTF-8?q?es=20that=20appear=20to=20be=20an=20argument=20to=20a=20message?= =?UTF-8?q?=20command.=20For=20example:=20false=20||=20ewarn=20"foo=20$WOR?= =?UTF-8?q?KDIR/bar=20baz"=20Thanks=20to=20Diego=20'Flameeyes'=20Petten?= =?UTF-8?q?=C3=B2=20=20for=20reporting=20this=20issue=20(cu?= =?UTF-8?q?rrently=20triggered=20by=20ruby-prof-0.7.0.ebuild).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/main/trunk/; revision=11913 --- pym/repoman/checks.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'pym') diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index dd81d8716..c9415b759 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -83,8 +83,11 @@ class EbuildQuote(LineCheck): """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc...""" repoman_check_name = 'ebuild.minorsyn' - _ignored_commands = ["echo", "local", "export"] - _ignored_commands += ["eerror", "einfo", "elog", "eqawarn", "ewarn"] + _message_commands = ["die", "echo", "eerror", + "einfo", "elog", "eqawarn", "ewarn"] + _message_re = re.compile(r'\s(' + "|".join(_message_commands) + \ + r')\s+"[^"]*"\s*$') + _ignored_commands = ["local", "export"] + _message_commands ignore_line = re.compile(r'(^$)|(^\s*#.*)|(^\s*\w+=.*)' + \ r'|(^\s*(' + "|".join(_ignored_commands) + r')\s+)') var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] @@ -125,6 +128,15 @@ class EbuildQuote(LineCheck): if self.var_reference.search(group) is None: continue + # Filter matches that appear to be an + # argument to a message command. + # For example: false || ewarn "foo $WORKDIR/bar baz" + message_match = self._message_re.search(line) + if message_match is not None and \ + message_match.start() < pos and \ + message_match.end() > pos: + break + # This is an attempt to avoid false positives without getting # too complex, while possibly allowing some (hopefully # unlikely) violations to slip through. We just assume -- cgit v1.2.3-1-g7c22