[ 
https://issues.apache.org/jira/browse/GROOVY-12341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110875#comment-18110875
 ] 

ASF GitHub Bot commented on GROOVY-12341:
-----------------------------------------

paulk-asert opened a new pull request, #2865:
URL: https://github.com/apache/groovy/pull/2865

   … fix
   
   /ls wrote file names and symlink targets into styled terminal output as they 
came off disk. A name is data supplied by whoever created it, not text the user 
asked to render, so an escape sequence embedded in one is executed by the 
terminal - hiding output, spoofing what is displayed, or reaching an emulator 
bug. coreutils and BSD ls quote such characters for this reason.
   
   JLine fixed this upstream in 4.4.1 (jline#2200) and Groovy does not receive 
it: GroovyPosixCommands is a fork, and Main.posixCommand dispatches /ls, /wc, 
/head, /tail and /grep to it, registering JLine's implementations only so their 
--help text can be read. Bumping the dependency upgrades code these commands 
never run. The helper and its ten call sites are therefore ported here, 
matching upstream one for one.
   
   Ported rather than improved on, deliberately. Upstream strips the control 
characters; coreutils quotes them, which preserves the distinction between two 
names that differ only by what was stripped. Quoting may well be better, but 
rewriting it here is how this file drifted far enough to miss the fix in the 
first place - that argument belongs upstream, where everyone would get the 
result.
   
   Stripping removes the ESC that makes a sequence a command and leaves the 
printable remainder, which is inert; the tests assert exactly that, since the 
surrounding output legitimately carries escapes of its own for colour.
   
   jline#2052, which restricts getSources to local jar: archives, is not 
ported: this fork has no jar: branch to restrict. The lasting fix for both is 
to stop forking - see the register's note on teaching upstream getSources to 
read a variable, which would let this file be deleted and take this patch with 
it.




> sync GroovyPosixCommands with the JLine 4.4.1
> ---------------------------------------------
>
>                 Key: GROOVY-12341
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12341
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Priority: Major
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to