Bug 63834 - "a" , "i" command get error on mod_sed
Summary: "a" , "i" command get error on mod_sed
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_sed (show other bugs)
Version: 2.4.41
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-11 02:48 UTC by Makoto Murata
Modified: 2019-10-11 02:48 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Makoto Murata 2019-10-11 02:48:38 UTC
Hello.

I want to add some new line to output HTML by using mod_sed.
I worte configuration file following,

---
OutputSed    '/^HOGEHOGE$/aFUGAFUGA'
---

but this configuration get error on syntax check.

---
$ sudo /usr/local/apache2/bin/apachectl -t
AH00526: Syntax error on line 81 of /usr/local/apache2/conf/httpd.conf:
Failed to compile sed expression. command garbled: /^HOGEHOGE$/aFUGAFUGA
---

I read the source cord causing this error. In modules/filters/sed0.c ,l365〜l376,
there is following check.

---
        case 'a':
            commands->rep->command = ACOM;
            if (commands->rep->ad2) {
                command_errf(commands, SEDERR_AD1MES, commands->linebuf);
                return -1;
            }
            if (*commands->cp == '\\') 
                commands->cp++;
            if (*commands->cp++ != '\n') {
                command_errf(commands, SEDERR_CGMES, commands->linebuf);
                return -1;
            }
---

It seems to require a backslash and a newline after "a" command.
In the "native" sed, this command works perfectly.

---
# sed -e '/^HOGEHOGE/aFUGAFUGA' textfile
---


Actually, sed man page says as following.
---
a \
text
---

I think this error check is unnecessary.
There is a similar check for the c and i commands.
Could you consider removing it?

Thanks.