Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better bash escaping in docker runner script
bug fixing handle the new lines don't miss port options more escaping in env
- Loading branch information
Showing
3 changed files
with
71 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...yExecutor/src/main/java/com/hubspot/singularity/executor/handlebars/ShellQuoteHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.hubspot.singularity.executor.handlebars; | ||
|
||
import java.io.IOException; | ||
|
||
import com.github.jknack.handlebars.Helper; | ||
import com.github.jknack.handlebars.Options; | ||
|
||
public class ShellQuoteHelper implements Helper<Object> { | ||
|
||
public static final String NAME = "shellQuote"; | ||
|
||
@Override | ||
public CharSequence apply(Object context, Options options) throws IOException { | ||
if (context == null) { | ||
return "''"; | ||
} | ||
|
||
final StringBuilder sb = new StringBuilder(); | ||
|
||
sb.append("'"); | ||
|
||
for (char c : context.toString().toCharArray()) { | ||
if (c == '\'') { | ||
sb.append("'\"'\"'"); | ||
} else if (c == '\n') { | ||
sb.append('\\'); | ||
sb.append('n'); | ||
} else { | ||
sb.append(c); | ||
} | ||
} | ||
|
||
sb.append("'"); | ||
|
||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4a5c6d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢