107 Commits

Author SHA1 Message Date
dd98030cb3 expand UNC checking
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1927033 13f79535-47bb-0310-9956-ffa450edef68
2025-07-07 11:49:48 +00:00
9771a826fd Add the escapehtml function to the expression API
Add the escapehtml function to the expression API, allowing to escape HTML
strings to guard against HTML injections.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1926342 13f79535-47bb-0310-9956-ffa450edef68
2025-06-10 15:31:19 +00:00
4599b709bb Fix a possible null pointer dereference in ap_expr_parse()
In ap_expr_parse(), ap_expr_yylex_init() will return 1 on failure,
and ctx.scanner will remain NULL. However the return value of
ap_expr_yylex_init() is not checked, and there is a dereference of
ctx.scanner in following function ap_expr_yyset_extra(),
which may lead to NULL pointer dereference.

Fix this bug by adding return value check of ap_expr_yylex_init.

Submitted by: Zhou Qingyang <zhou1615@umn.edu>

Github: closes #308


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908772 13f79535-47bb-0310-9956-ffa450edef68
2023-03-28 21:12:47 +00:00
bf6c900db7 There is no point in calling ap_varbuf_grow() here, it is already
called from within ap_varbuf_strmemcat().

Moreover, 2nd parameter should be the minimum total new length, not
the amount of the growth. So this call is likely to be a no-op.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1898286 13f79535-47bb-0310-9956-ffa450edef68
2022-02-21 21:07:35 +00:00
700d9b5b5b clarification/fixes around the replace() function
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1891990 13f79535-47bb-0310-9956-ffa450edef68
2021-08-03 18:29:35 +00:00
587d170151 *) core: provide ap_ssl_* functions in new http_ssl.h header file.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1888083 13f79535-47bb-0310-9956-ffa450edef68
2021-03-26 11:27:34 +00:00
7c5e4c9ab2 Using the new ap_ssl_conn_is_ssl() and ap_ssl_var_lookup() in all internal modules.
* leaving mod_nw_ssl and mod_ssl itself untouched
 * removing mod_ssl.h includes where no longer necessary
 * some modules might skip post_config hooks, but those were left in, even when empty now.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1887364 13f79535-47bb-0310-9956-ffa450edef68
2021-03-09 12:55:55 +00:00
74d32d7baf Fix a few warnings on 64 bits windows compilation
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1881303 13f79535-47bb-0310-9956-ffa450edef68
2020-08-29 20:30:41 +00:00
34745a1892 util_expr: allow to specify only one of ap_expr_eval_ctx_t's r/c/s.
Depending on where the expression is evaluated, a request_rec might not be
available, so allow to specify only a conn_rec or a server_rec (at least) in
the passed in ap_expr_eval_ctx_t.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1877550 13f79535-47bb-0310-9956-ffa450edef68
2020-05-10 15:15:21 +00:00
58c4c85ff7 Constify pointers in ap_expr lookup tables, as well as the already
const pointed-to strings.  ~1/2Kb moves to r/o text section, size(1)
diff:

    text           data     bss     dec     hex filename
- 667519          18384   13952  699855   aadcf httpd
+ 668015          17864   13952  699831   aadb7 httpd

* server/util_expr_eval.c
  [*_var_names, expr_provider_multi]: Mark pointers in name
  lists as const.
  (core_expr_lookup): Adjust accordingly.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1877350 13f79535-47bb-0310-9956-ffa450edef68
2020-05-04 10:48:55 +00:00
85760859ca Fix spelling errors found by codespell. [skip ci]
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1873985 13f79535-47bb-0310-9956-ffa450edef68
2020-02-13 18:15:57 +00:00
a0788858f2 Fix a typo reported by [stephane.blondon gmail.com]
PR 63092

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1851702 13f79535-47bb-0310-9956-ffa450edef68
2019-01-20 09:55:41 +00:00
4be1913dd2 Fix a potential un-intialized variable usage warning.
This can not be a runtime ixsue, because, in such a case, we would assert and abort before.

 PR 59819.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1832317 13f79535-47bb-0310-9956-ffa450edef68
2018-05-26 16:54:23 +00:00
9246096892 * server/util_expr_eval.c (ap_expr_eval_re_backref): Fix gcc 7.x warning.
util_expr_eval.c: In function ‘ap_expr_eval_re_backref’:
util_expr_eval.c:265:63: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
     if (!ctx->re_pmatch || !ctx->re_source || *ctx->re_source == '\0' ||


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1812307 13f79535-47bb-0310-9956-ffa450edef68
2017-10-16 16:40:52 +00:00
e172ca33e2 ap_expr: follow up to r1810605.
The "split" and "join" operators are now a prefix, ala perl.
Add the "sub" operator for string substitutions, prefix still.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1811104 13f79535-47bb-0310-9956-ffa450edef68
2017-10-04 16:18:46 +00:00
4f6af33ff1 apr_expr: follow up to r1810605.
Not necessarily ASCII here..



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1810702 13f79535-47bb-0310-9956-ffa450edef68
2017-10-03 09:23:32 +00:00
08ddf7ad0a ap_expr: open string expressions to the <word>.
Introduces the syntax "%{:<word>:}", borrowed from the <var>'s one, and which
likewise can be embedded anywhere in a string expression (the same reserved
character ':' gets reused in an unambiguous manner).

This allows the two types of expressions (boolean and string) to now share
fully the same language set, namely: strings, lists, vars, regexes, backrefs,
functions with multiple or complex arguments, and especially combinations
thereof.

Most of them were reserved to boolean expressions only, while complex string
constructions can also benefit to, well, strings. The <word> construct allows
that (say the syntax "%{:<word>:}" looks like a temporary variable constructed
in a string).

Since string expressions may now have to deal with lists (arrays), they also
need a way to produce/extract strings from list and vice versa. This can be
done with the new "join" and "split" operators, while the new substitution
regexes (like "s/<pattern>/<substitute>/<flags>") may be used to manipulate
strings in place. All this of course available for both string and boolean
expressions.

Tests and doc updates upcoming..



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1810605 13f79535-47bb-0310-9956-ffa450edef68
2017-10-02 21:57:26 +00:00
714394efe3 mod_rewrite,core: avoid Vary:Host (part 2)
This is a follow up of r1808746 after a chat
with Yann on dev@:

- the HTTP:Host variable suffers from the same problem
- the strcasecmp should be used to allow case-sensitive
  comparisons.
- in mod_rewrite is less cumbersome and more clean to just
  make the Host header check in lookup_header, so it will
  be automatically picked up by every part of the code
  that uses it. It shouldn't be a relevant overhead for
  mod_rewrite.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1809028 13f79535-47bb-0310-9956-ffa450edef68
2017-09-20 13:03:41 +00:00
bc0f112313 mod_rewrite/core: avoid the 'Vary: Host' header
In PR 58231 is was brought up that httpd adds the
Vary: Host header whenever a condition is set to true
in mod_rewrite or in an <If> block.

The https://tools.ietf.org/html/rfc7231#section-7.1.4
section seems to disallow this use case:

"The "Vary" header field in a response describes "
"what parts of a request message, "
"aside from the method, Host header field, [...]"

I had a chat with the folks in #traffic-server and
they don't see much point in having a Vary: Host header,
plus it was reported that Varnish doesn't like it very
much (namely it does not cache the response when
it sees the header, links of the report in the PR).

I don't see much value in this behavior of httpd so
I am inclined to remove this response header value,
but I'd be glad to get a more experienced opinion.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1808746 13f79535-47bb-0310-9956-ffa450edef68
2017-09-18 17:08:54 +00:00
fe3c9b7a0f Fix %{DOCUMENT_URI} in SSI w/ default parser
*) core: %{DOCUMENT_URI} used in nested SSI expressions should point to the
     URI originally requsted by the user, not the nested documents URI. This
     restores the behavior of this variable to match the "legacy" SSI parser.
     PR60624. 

Submitted By [Hank Ibell <hwibell gmail.com>]



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1780095 13f79535-47bb-0310-9956-ffa450edef68
2017-01-24 17:09:47 +00:00
b3531c422d PR59938: add %{REMOTE_PORT} to the expression parser
Submitted By: Hank Ibell <hwibell gmail.com>



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1776459 13f79535-47bb-0310-9956-ffa450edef68
2016-12-29 18:31:13 +00:00
f4cc76ee71 Rename ap_casecmpstr[n]() to ap_cstr_casecmp[n](), update with APR doxygen
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1747469 13f79535-47bb-0310-9956-ffa450edef68
2016-06-09 00:06:42 +00:00
690c6105f9 hostname: Test and log useragent_host per-request across various modules,
including the scoreboard, expression and rewrite engines, setenvif,
authz_host, access_compat, custom logging, ssl and REMOTE_HOST variables.
PR55348  [William Rowe]

This is the complete change set which applies cleanly to 2.4.x as well,
the server/scoreboard.c will follow, which does not apply due to drift.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1729930 13f79535-47bb-0310-9956-ffa450edef68
2016-02-12 01:17:03 +00:00
44026b36fa expr support for HTTP2 variable
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1726167 13f79535-47bb-0310-9956-ffa450edef68
2016-01-22 10:09:28 +00:00
df23b8a678 revert
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1726057 13f79535-47bb-0310-9956-ffa450edef68
2016-01-21 18:41:21 +00:00
e0318bf236 expand and err-check...
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725766 13f79535-47bb-0310-9956-ffa450edef68
2016-01-20 17:54:38 +00:00
05a31cb629 Just in case...
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725762 13f79535-47bb-0310-9956-ffa450edef68
2016-01-20 17:37:19 +00:00
b0ba54040b ap_expr now allows kept_body() function to grab/use
response body if stored in r->kept_body


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725755 13f79535-47bb-0310-9956-ffa450edef68
2016-01-20 16:58:04 +00:00
0eddea67ac Added some more log numbers to log statements that
had none.

Those were not detected by the coccinelle script.
Only a few hard cases are remaining now.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725548 13f79535-47bb-0310-9956-ffa450edef68
2016-01-19 15:43:17 +00:00
4bfe0a6bba Follow up to r1715880: revert more abusive ap_casecmpstr[n]() usages.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1722150 13f79535-47bb-0310-9956-ffa450edef68
2015-12-29 15:32:27 +00:00
7e96ac17cf Use 'ap_array_str_contains' to simplify code.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1719255 13f79535-47bb-0310-9956-ffa450edef68
2015-12-11 04:40:20 +00:00
c80e6b2a34 Use new ap_casecmpstr[n]() functions where appropriate (not exhaustive).
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715876 13f79535-47bb-0310-9956-ffa450edef68
2015-11-23 16:46:01 +00:00
3c9ddf44bf Revert r1715789: will re-commit without spurious functional changes.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715869 13f79535-47bb-0310-9956-ffa450edef68
2015-11-23 16:28:36 +00:00
29843dc73f Use new ap_casecmpstr[n]() functions where appropriate (not exhaustive).
[Reverted by r1715869]


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715789 13f79535-47bb-0310-9956-ffa450edef68
2015-11-23 12:33:09 +00:00
a58cc8eef0 reverting unwanted loss of missing case
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1702954 13f79535-47bb-0310-9956-ffa450edef68
2015-09-14 13:57:09 +00:00
ea390af213 httpd compiles warning free on gcc and every new warning will be treated as an error, standard c-89 is enforced
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1702948 13f79535-47bb-0310-9956-ffa450edef68
2015-09-14 13:29:35 +00:00
7439a429d6 Expression parser: Optimize another concatenation
case by using iteration instead of recursion.

We have a relatively small recursion limit of
about 10 operations. This is a compilation
limit (a define). It can be hit if many expr
vars or function calls are concatenated.

The new optimization is very similar to the
existing one, which optimizes consecutive
concatenations in node2 of the tree. The new
one optimizes consecutive concatenations in
node 1.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1657685 13f79535-47bb-0310-9956-ffa450edef68
2015-02-05 20:33:59 +00:00
829e98c57d looks like debug left in r1642154
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1647125 13f79535-47bb-0310-9956-ffa450edef68
2014-12-21 11:47:26 +00:00
ddc48bf250 * Correctly indent
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643220 13f79535-47bb-0310-9956-ffa450edef68
2014-12-05 10:02:57 +00:00
f1d7ed9cde ap_expr: Add filemod function for checking file modification times.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643145 13f79535-47bb-0310-9956-ffa450edef68
2014-12-05 00:46:33 +00:00
529b4906a6 * ap_expr: Fix replace() func when length of "from" != length of "to".
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643094 13f79535-47bb-0310-9956-ffa450edef68
2014-12-03 11:10:50 +00:00
bd41584fcb * ap_exr: Add replace(string, from, to) function.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1642154 13f79535-47bb-0310-9956-ffa450edef68
2014-11-27 13:46:11 +00:00
268e463e27 tab vs space
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1633528 13f79535-47bb-0310-9956-ffa450edef68
2014-10-22 05:22:09 +00:00
2785b009e9 Silent some cppcheck warnings.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1621806 13f79535-47bb-0310-9956-ffa450edef68
2014-09-01 14:40:01 +00:00
089d2e0373 Do not use deprecated define.
No change in generated code because MODULE_MAGIC_NUMBER is defined as:
   #define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1611871 13f79535-47bb-0310-9956-ffa450edef68
2014-07-19 09:46:20 +00:00
80e41b5819 Tweak a AP_DEBUG_ASSERT condition.
Valid index to use 'req_header_var_names' are 0...6

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1595321 13f79535-47bb-0310-9956-ffa450edef68
2014-05-16 19:37:07 +00:00
1c88c53282 Only include the ldap escaping if present within APR.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1589995 13f79535-47bb-0310-9956-ffa450edef68
2014-04-25 11:19:56 +00:00
7c05d5e069 Add the ldap function to the expression API, allowing LDAP filters and
distinguished names based on expressions to be escaped correctly to
guard against LDAP injection.

Note: this requires at least APR v1.6.0 or above for the apr_escape API.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1589986 13f79535-47bb-0310-9956-ffa450edef68
2014-04-25 10:55:04 +00:00
a3dca551c1 Move two variable assignments off the fast path.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1588448 13f79535-47bb-0310-9956-ffa450edef68
2014-04-18 11:47:06 +00:00
2f358e7e17 add md5 function, too
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1458004 13f79535-47bb-0310-9956-ffa450edef68
2013-03-18 21:16:18 +00:00