Commit Graph

12 Commits

Author SHA1 Message Date
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
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
96131fdd9e Provide better token names for error messages
Use either human readable names or the exact spelling from the BNF from the
docs.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1493414 13f79535-47bb-0310-9956-ffa450edef68
2013-06-15 20:48:34 +00:00
92663b1e32 Limit recursion in ap_expr evaluation to avoid unbounded stack usage
* evaluate chains of ||, &&, and string concatenation non-recursively
* limit other types of recursion to 20 levels
* avoid some string copies if concatenating more than 2 strings


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1204087 13f79535-47bb-0310-9956-ffa450edef68
2011-11-19 21:58:48 +00:00
f64bd9fc9b Improve error message by removing 'unexpected T_ERROR' in one case.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1181230 13f79535-47bb-0310-9956-ffa450edef68
2011-10-10 20:41:26 +00:00
8281a318cf Do proper length checks in the expression scanner. This allows to remove the
8K length limit for expressions. Strings/Regexs in an expression are still
limited to 8K, though.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1157362 13f79535-47bb-0310-9956-ffa450edef68
2011-08-13 09:59:43 +00:00
46d4791a5d Add string valued expressions to ap_expr, do some API cleanup
- add possibility to have expressions that evaluate to a string and not to
  a boolean value
- modify ap_expr_parse_cmd() interface to support this and make it more
  convenient to use in general
- rename AP_EXPR_FLAGS_* to AP_EXPR_FLAG_* for consistency


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1142164 13f79535-47bb-0310-9956-ffa450edef68
2011-07-02 07:45:00 +00:00
b93e49391b Rename ap_expr's typedef names:
ap_expr            ->  ap_expr_t
ap_expr_parse_ctx  ->  ap_expr_parse_ctx_t
ap_expr_eval_ctx   ->  ap_expr_eval_ctx_t
ap_expr_lookup_fn  ->  ap_expr_lookup_fn_t
ap_expr_node_op    ->  ap_expr_node_op_e


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1042146 13f79535-47bb-0310-9956-ffa450edef68
2010-12-04 11:22:30 +00:00
e27a3c21e3 - add -ipmatch, -str(c)match, -fnmatch, -R operators to ap_expr
- allow lookup function to pre-parse string constant arguments 
  (used for subnet masks so far)
- various bug fixes for binary operators
- do strdup() for error messages created on the stack to avoid corruption


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1039900 13f79535-47bb-0310-9956-ffa450edef68
2010-11-28 16:35:14 +00:00
cf0e2c3a46 Fix some Windows build issues
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1039204 13f79535-47bb-0310-9956-ffa450edef68
2010-11-25 22:27:17 +00:00
6ef1911acc ap_expr related fixes/enhancements:
- implement regex backreferences and make them available for setting 
  envvars in SetEnvIfExpr
- implement nested function calls in %-syntax: %{func1:%{func2:arg}} 
- actually implement evaluation of concatenation operator (oops...)
- Fix <If ... > treating an internal error as success


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1037504 13f79535-47bb-0310-9956-ffa450edef68
2010-11-21 17:22:26 +00:00
35cdba6976 Replace ap_expr with a parser derived from mod_ssl's parser. Make mod_ssl use
the new parser. Rework ap_expr's public interface and provide hooks for modules
to add variables and functions.

The Netware and Windows build files still need to be adjusted


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1032073 13f79535-47bb-0310-9956-ffa450edef68
2010-11-06 14:31:16 +00:00