Skip to content

Commit

Permalink
fix(Escpaing): Remove xterm escape codes from log file
Browse files Browse the repository at this point in the history
fixes JENKINS-73604
  • Loading branch information
mydeveloperday authored Nov 28, 2024
1 parent 5ccf553 commit 1b40ade
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/hudson/plugins/logparser/LogParserParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ public String parseLine(final String line) throws IOException {
return parseLine(line, null);
}

public static String convertEscapeSequencesToHtml(String text) {
// Remove xterm color escape sequence with an empty space.
return text.replaceAll("\u001B\\[(\\d{1,2})(;\\d{1,2})?(;\\d{1,2})?m", "");
}

public String parseLine(final String line, final String status)
throws IOException {
String parsedLine = line;
Expand All @@ -235,6 +240,9 @@ public String parseLine(final String line, final String status)
// Allows > to be seen in log which is html
parsedLine = parsedLine.replaceAll(">", ">");

// Remove xterm color escape sequence with an empty space.
parsedLine = convertEscapeSequencesToHtml(parsedLine);

if (effectiveStatus != null
&& !effectiveStatus.equals(LogParserConsts.NONE)) {
// Increment count of the status
Expand Down

0 comments on commit 1b40ade

Please sign in to comment.