Skip to content
Permalink
Browse files

[FIXED JENKINS-12782] Don't match word boundary if first or last

character is not alpha numeric.
  • Loading branch information...
uhafner committed Feb 20, 2012
1 parent 02d2b39 commit 0e484b07198f41851bda4c3bf5a02161d1077e8b
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/localizer">
@@ -67,5 +67,11 @@ public String getMatch() {
return getType() + ": " + getDetailMessage();
}
}

/** {@inheritDoc} */
@Override
public String toString() {
return super.toString() + getDetailMessage();
}
}

@@ -87,12 +87,15 @@ private Pattern compile(final String tagIdentifiers, final boolean ignoreCase) {
for (int i = 0; i < tags.length; i++) {
String tag = tags[i].trim();
if (StringUtils.isNotBlank(tag)) {
StringBuilder actual = new StringBuilder();
if (Character.isLetterOrDigit(tag.charAt(0))) {
regexps.add(WORD_BOUNDARY + tag + WORD_BOUNDARY);
actual.append(WORD_BOUNDARY);
}
else {
regexps.add(tag + WORD_BOUNDARY);
actual.append(tag);
if (Character.isLetterOrDigit(tag.charAt(tag.length() - 1))) {
actual.append(WORD_BOUNDARY);
}
regexps.add(actual.toString());
}
}
int flags;
@@ -34,6 +34,21 @@
/** Error message. */
private static final String WRONG_NUMBER_OF_TASKS_ERROR = "Wrong number of tasks found.";

/**
* Parses a warning log with !!! and !!!! warnings.
*
* @throws IOException
* if the file could not be read
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-12782">Issue 12782</a>
*/
@Test
public void issue12782() throws IOException {
InputStream file = TaskScannerTest.class.getResourceAsStream("issue12782.txt");

Collection<Task> result = new TaskScanner("!!!!!", "!!!", "", false).scan(new InputStreamReader(file));
assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 3, result.size());
}

/**
* Checks whether we find tasks at word boundaries.
*
@@ -0,0 +1,6 @@
This is a text

!!!: here we have a task with priority NORMAL

!!!!!: here another task with priority HIGH

0 comments on commit 0e484b0

Please sign in to comment.
You can’t perform that action at this time.