From 263b91d5561931340bfdbce1cef91c65a656b859 Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Thu, 28 Aug 2008 01:04:34 +0000 Subject: [PATCH] Fixed bug 2050064 - False + SuspiciousOctalEscape with backslash literal git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6415 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/changelog.txt | 1 + .../xml/SuspiciousOctalEscape.xml | 26 +++++++++++++++++++ .../pmd/rules/SuspiciousOctalEscape.java | 2 ++ 3 files changed, 29 insertions(+) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 1b217185c6..59bd496044 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -12,6 +12,7 @@ Fixed bug 1998185 - BeanMembersShouldSerialize vs @SuppressWarnings("serial") Fixed bug 2002722 - false + in UseStringBufferForStringAppends Fixed bug 2056318 - False positive for AvoidInstantiatingObjectsInLoops Fixed bug 1977438 - False positive for UselessStringValueOf +Fixed bug 2050064 - False + SuspiciousOctalEscape with backslash literal Optimizations and false positive fixes in PreserveStackTrace @SuppressWarnings("all") disables all warnings All comment types are now stored in ASTCompilationUnit, not just formal ones diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/controversial/xml/SuspiciousOctalEscape.xml b/pmd/regress/test/net/sourceforge/pmd/rules/controversial/xml/SuspiciousOctalEscape.xml index 90d9aa5ad0..cb05da5fde 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/controversial/xml/SuspiciousOctalEscape.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/controversial/xml/SuspiciousOctalEscape.xml @@ -49,6 +49,32 @@ public class Foo { void bar() { System.out.println("foo = \4008"); } +} + ]]> + + + + 0 + + + + + 1 + diff --git a/pmd/src/net/sourceforge/pmd/rules/SuspiciousOctalEscape.java b/pmd/src/net/sourceforge/pmd/rules/SuspiciousOctalEscape.java index b044154d9b..7ce52dde5e 100644 --- a/pmd/src/net/sourceforge/pmd/rules/SuspiciousOctalEscape.java +++ b/pmd/src/net/sourceforge/pmd/rules/SuspiciousOctalEscape.java @@ -57,6 +57,8 @@ public class SuspiciousOctalEscape extends AbstractRule { addViolation(data, node); } } + } else if (first == '\\') { + slash++; } offset = slash + 1;