Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2020-05-24 11:10:24 +0000
committerPaul Pazderski2020-06-30 16:52:46 +0000
commitdf0a30251c7d67951b24884e2c3cc71c4bb69b3e (patch)
treec1e80a25a67f85648766366783245633d8bdf16b /org.eclipse.ui.console
parentf624f1e041e6e85acf4d750fd92b5d08c5cca71a (diff)
downloadeclipse.platform.debug-df0a30251c7d67951b24884e2c3cc71c4bb69b3e.tar.gz
eclipse.platform.debug-df0a30251c7d67951b24884e2c3cc71c4bb69b3e.tar.xz
eclipse.platform.debug-df0a30251c7d67951b24884e2c3cc71c4bb69b3e.zip
If interpretation of ASCII control characters is enabled handle null bytes (\0) by simply filtering them out. This is useful because null bytes can truncate console lines on some platforms and brings unexpected results on copy text on most platforms. Change-Id: Ic6a46c3eba4582c8f54fcd6735b8763738d47623 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
index 6f593fe1b..0e448a6c1 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
@@ -98,12 +98,12 @@ public class IOConsolePartitioner
* Pattern used to find supported ASCII control characters <b>except</b>
* carriage return.
*/
- private static final String CONTROL_CHARACTERS_PATTERN_STR = "(?:\b+|\u000b+|\f+)"; //$NON-NLS-1$
+ private static final String CONTROL_CHARACTERS_PATTERN_STR = "(?:\b+|\u0000+|\u000b+|\f+)"; //$NON-NLS-1$
/**
* Pattern used to find supported ASCII control characters <b>including</b>
* carriage return.
*/
- private static final String CONTROL_CHARACTERS_WITH_CR_PATTERN_STR = "(?:\b+|\u000b+|\f+|\r+(?!\n))"; //$NON-NLS-1$
+ private static final String CONTROL_CHARACTERS_WITH_CR_PATTERN_STR = "(?:\b+|\u0000+|\u000b+|\f+|\r+(?!\n))"; //$NON-NLS-1$
/** The connected {@link IDocument} this partitioner manages. */
private IDocument document;
@@ -881,6 +881,7 @@ public class IOConsolePartitioner
applyOutputToDocument(content.toString(), nextWriteOffset, replaceLength);
content.setLength(0);
replaceLength = 0;
+ nextWriteOffset = outputOffset;
final String controlCharacterMatch = controlCharacterMatcher.group();
final char controlCharacter = controlCharacterMatch.charAt(0);
@@ -949,6 +950,13 @@ public class IOConsolePartitioner
partititonContent(pending.stream, vtab, 0, vtab.length());
break;
+ case 0:
+ // Do nothing for null bytes. The use of this is that a null byte which reach
+ // the IOConsoleViewer will truncate the line on some platforms and will disturb
+ // copying text on most platforms.
+ // This case should simply filter out any null bytes.
+ break;
+
default:
// should never happen as long as the used regex pattern is valid
log(IStatus.ERROR, "No implementation to handle control character 0x" //$NON-NLS-1$

Back to the top