Am 05.01.2015 um 19:14 schrieb Bowie Bailey:
On 1/4/2015 5:42 AM, Reindl Harald wrote:Am 04.01.2015 um 06:43 schrieb Bob Proulx:The additional issue was that you were referencing PHP documentation. Might as well have been referencing Lisp documentation for all of the relevance it had. That was the point I saw being addressed at that point. PHP is a similar syntax that came after Perl but it very much is its own thing and Perl does not derive from itwe are talking about PCRE and the PHP function preg_quote() to escape a string for *perl* regular expressions not the language syntax and since the backneds are alreay there i just asked *what* chars *additional* to that function needs to be escaped *besides* the @ i found out myself that is a short and simple question and not refer to the used PHP function would not have been hepful at allOk. Here is an attempt at a simple answer off the top of my head. (Not guaranteed to be complete) The following characters may need to be escaped in a Perl regex (as used in SA) if intended to be used as literal characters: $%@/[{*+?\ ] and } may need to be escaped as well, but I don't think it is required. You can avoid having to escape the slash (/) by using a different separator for the regex. This can avoid "leaning toothpick syndrome."
thanks, i ended last night in the wrapper-function below while / already got escaped since this is also needed for postfix header_checks
so finally there was only % missing i got aware on that thread, @ was already handeled after taking notice and the rest is done properly by preg_quote()
[harry@srv-rhsoft:/downloads]$ cat test.php #!/usr/bin/php <?php $chars = '$ % @ / [ ] { } \ * + ? ! \\'; echo $chars . "\n"; echo preg_quote($chars) . "\n"; echo sa_quote($chars) . "\n"; function sa_quote($input) { $input = str_replace(array("\n", "\r", "\0"), '', trim($input)); $input = str_replace("\t", ' ', $input); $input = preg_quote($input); $input = str_replace('/', '\/', $input); $input = str_replace('@', '\@', $input); $input = str_replace('%', '\%', $input); return $input; } ?> [harry@srv-rhsoft:/downloads]$ ./test.php $ % @ / [ ] { } \ * + ? ! \ \$ % @ / \[ \] \{ \} \\ \* \+ \? \! \\ \$ \% \@ \/ \[ \] \{ \} \\ \* \+ \? \! \\
signature.asc
Description: OpenPGP digital signature