On Sun, 3 Apr 2011, Ruediger Pluem wrote:
On 03/29/2011 11:29 PM, [email protected] wrote:
Author: sf
Date: Tue Mar 29 21:29:34 2011
New Revision: 1086756
URL: http://svn.apache.org/viewvc?rev=1086756&view=rev
Log:
Change the ap_cfg_getline() and ap_cfg_getc() to return an error code.
Also:
- Make ap_cfg_getline() return APR_ENOSPC if a config line is too long.
- Add ap_pcfg_strerror() function to convert ap_cfg_getline's return value
into a nice message.
- Adjust definition of ap_configfile_t accordingly.
Not bumping MMN because it has already been bumped today.
Modified: httpd/httpd/trunk/server/util.c
URL:
http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1086756&r1=1086755&r2=1086756&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Tue Mar 29 21:29:34 2011
- if (!(cp > cbuf && cp[-1] == '\\')) {
- /*
- * line continuation requested -
- * then remove backslash and continue
- */
- cbufsize -= (cp-cbuf);
- cbuf = cp;
- continue;
Why don't we consider escaped backslashes as literals any longer?
Because the code was wrong to begin with. To be correct, it would have to
treat "\\" at EOL differently from "\\\", but it didn't do that. And since
this feature was undocumented, I thought it was not worth the hassle. The
user can prevent line continuation by appending a space (and that's
documented).
- if (c == CR) {
- /* silently ignore CR (_assume_ that a LF follows) */
- c = cfp->getch(cfp->param);
Why don't we ignore CR any longer?
Any trailing CR is later removed together with other trailing whitespace.
I don't think we need to care about non-trailing CRs.
+
+ /*
+ * Leading and trailing white space is eliminated completely
+ */
+ src = buf;
+ while (apr_isspace(*src))
+ ++src;
+ /* blast trailing whitespace */
+ dst = &src[strlen(src)];
+ while (--dst >= src && apr_isspace(*dst))
+ *dst = '\0';
+ /* Zap leading whitespace by shifting */
+ if (src != buf)
+ memmove(buf, src, dst - src + 2);
Cheers,
Stefan