Skip to content

Commit

Permalink
Merge pull request #5299 from payara/FISH-1423-disable-escaping-asadmin
Browse files Browse the repository at this point in the history
FISH-1423 disable escaping asadmin
  • Loading branch information
kalinchan authored Jun 16, 2021
2 parents 8939b26 + d0b1a4d commit baf5e6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2019] Payara Foundation and/or affiliates
// Portions Copyright [2018-2021] Payara Foundation and/or affiliates

package com.sun.enterprise.admin.cli;

Expand Down Expand Up @@ -1440,12 +1440,25 @@ protected void buildTerminal() {

protected void buildLineReader() {
if (lineReader == null) {
lineReader = LineReaderBuilder.builder()
lineReader = newLineReaderBuilder()
.terminal(terminal)
.build();
}
}

protected LineReaderBuilder newLineReaderBuilder() {
// In community this should be disabled by default
boolean disabled = true;
Environment environment = this.env;
if(environment.hasOption("DISABLE_EVENT_EXPANSION")) {
disabled = environment.getBooleanOption("DISABLE_EVENT_EXPANSION");
}
return LineReaderBuilder.builder()
.appName(ASADMIN)
// disable event expansion because it swallows backslashes and we don't need to support events
.option(LineReader.Option.DISABLE_EVENT_EXPANSION, disabled);
}

protected void closeTerminal() {
try {
if (terminal != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2019] Payara Foundation and/or affiliates
// Portions Copyright [2018-2021] Payara Foundation and/or affiliates

package com.sun.enterprise.admin.cli;

Expand All @@ -61,7 +61,6 @@
import org.jline.reader.Completer;
import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;
import org.jline.reader.impl.completer.StringsCompleter;
import org.jline.terminal.Terminal;
Expand Down Expand Up @@ -149,8 +148,7 @@ protected int executeCommand() throws CommandException, CommandValidationExcepti
.encoding(encoding != null ? Charset.forName(encoding) : Charset.defaultCharset())
.build();

reader = LineReaderBuilder.builder()
.appName(ASADMIN)
reader = newLineReaderBuilder()
.terminal(asadminTerminal)
.completer(completer)
.build();
Expand Down Expand Up @@ -183,9 +181,8 @@ public void write(byte[] b, int off, int len) throws IOException {
Terminal asadminTerminal = new ExternalTerminal(ASADMIN, "",
new FileInputStream(file), out, encoding != null ? Charset.forName(encoding) : Charset.defaultCharset());

reader = LineReaderBuilder.builder()
reader = newLineReaderBuilder()
.terminal(asadminTerminal)
.appName(ASADMIN)
.build();
}

Expand Down

0 comments on commit baf5e6a

Please sign in to comment.