File: README.md

package info (click to toggle)
libvmod-re2 2.0.0%2B20250617-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 708 kB
  • sloc: ansic: 1,518; cpp: 514; makefile: 111; sh: 38; ruby: 36
file content (71 lines) | stat: -rw-r--r-- 2,607 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# vmod\_re2

## Varnish Module for access to the Google RE2 regular expression engine

### DESCRIPTION

Varnish Module (VMOD) for access to the Google RE2 regular expression
engine.

Varnish VCL uses the PCRE library (Perl Compatible Regular Expressions)
for its native regular expressions, which runs very efficiently for many
common uses of pattern matching in VCL, as attested by years of
successful use of PCRE with Varnish.

But for certain kinds of patterns, the worst-case running time of the
PCRE matcher is exponential in the length of the string to be matched.
The matcher uses backtracking, implemented with recursive calls to the
internal `match()` function. In principle there is no upper bound to the
possible depth of backtracking and recursion, except as imposed by the
`varnishd` runtime parameters `pcre_match_limit` and
`pcre_match_limit_recursion`; matches fail if either of these limits are
met. Stack overflow caused by deep backtracking has occasionally been
the subject of `varnishd` issues.

RE2 differs from PCRE in that it limits the syntax of patterns so that
they always specify a regular language in the formally strict sense.
Most notably, backreferences within a pattern are not permitted, for
example `(foo|bar)\1` to match `foofoo` and `barbar`, but not `foobar`
or `barfoo`. See the link in `SEE ALSO` for the specification of RE2
syntax.

This means that an RE2 matcher runs as a finite automaton, which
guarantees linear running time in the length of the matched string.
There is no backtracking, and hence no risk of deep recursion or stack
overflow.

The relative advantages and disadvantages of RE2 and PCRE is a broad
subject, beyond the scope of this manual. See the references in `SEE
ALSO` for more in-depth discussion.

### INSTALLATION

See [INSTALL.rst](INSTALL.rst) in the source repository.

### AUTHOR

  - Geoffrey Simmons \<<geoff@uplex.de>\>

UPLEX Nils Goroll Systemoptimierung

### SEE ALSO

  - varnishd(1)
  - vcl(7)
  - VMOD source repository:
    <https://code.uplex.de/uplex-varnish/libvmod-re2>
      - Gitlab mirror: <https://gitlab.com/uplex/varnish/libvmod-re2>
  - RE2 git repo: <https://github.com/google/re2>
  - RE2 syntax: <https://github.com/google/re2/wiki/Syntax>
  - "Implementing Regular Expressions": <https://swtch.com/~rsc/regexp/>
      - Series of articles motivating the design of RE2, with discussion
        of how RE2 compares with PCRE

### COPYRIGHT

    Copyright (c) 2016-2018 UPLEX Nils Goroll Systemoptimierung
    All rights reserved
    
    Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
    
    See LICENSE