Re: [code] [textadept] Curses `os.spawn` Shell String Parsing

From: Mitchell <m.att.foicica.com>
Date: Mon, 17 Dec 2018 13:54:20 -0500 (EST)

Hi Chad,

On Thu, 13 Dec 2018, Mitchell wrote:

> Hi Chad,
>
> On Wed, 12 Dec 2018, Chad Voegele wrote:
>
>> Hi Mitchell,
>>
>> I use `sed` with `filter_through` for search and replace and have been
>> having trouble when trying to replace single quotes with double
>> quotes, i.e. `filter_through('sed "s/\'/\\"/g"')`. I narrowed the
>> issue to an implementation difference where the curses version uses
>> custom logic to parse the shell string. Lines 807-817 in the patched
>> `loslib.c` seem to have trouble with the escaped double quote.
>>
>> Since I'm guessing you would not like to have a `glib` dependency in
>> the curses version, one option to fix this could be to use the POSIX
>> function `wordexp` provided by `libc`. Please see the patch below for
>> details. Would you be willing to consider adopting this patch or
>> something similar?
>>
>> [snip]
>
> This looks good to me. I'll apply something similar when I have some time.
> Thanks!

After looking into `wordexp` support on Mac and the BSDs, I discovered that the function is frowned upon for its poor security. Instead, I committed a fix that handles escaped double-quote characters[1], so your "sed" case is handled properly. Let me know if there are still bugs.

Cheers,
Mitchell

[1]: https://foicica.com/hg/textadept/rev/2ccdb437f236

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Mon 17 Dec 2018 - 13:54:20 EST

This archive was generated by hypermail 2.2.0 : Tue 18 Dec 2018 - 06:31:14 EST