Commit f87e800c authored by Geoff Simmons's avatar Geoff Simmons

Abandon the attempt to support the 16- and 32-bit pcre2 libraries.

UTF-16 and -32 would require strings to include null bytes; this is
the case for all code points that correspond to ASCII. But a VCL
literal STRING by definition may not have a null byte (see vcl(3)).
So we couldn't have a pattern in a literal STRING, and that's the
show stopper. We also could not match regexen against literal strings;
that might not happen much in production, but it could in principle,
and the VMOD would have match against literal strings in the vtc tests.
So, maybe some day when we support matching against BLOBs (although
for that, we'd have to declare the pattern in a BLOB, which might
be just too odd).
parent 2a871ac1
......@@ -37,10 +37,10 @@ expresion library.
CONTENTS
========
* regex(STRING, ENUM {LIB8,LIB16,LIB32}, BOOL, BOOL, ENUM {ANYCRLF,UNICODE}, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, STRING, BOOL, INT, BOOL, BOOL, BOOL, BOOL, ENUM {CR,LF,CRLF,ANYCRLF,ANY}, BOOL, BOOL, BOOL, BOOL, BOOL, INT, BOOL, BOOL, BOOL, BOOL)
* BOOL config_bool(ENUM {JIT,STACKRECURSE,UNICODE}, ENUM {LIB8,LIB16,LIB32})
* STRING config_str(ENUM {BSR,JITTARGET,NEWLINE,UNICODE_VERSION,VERSION}, ENUM {LIB8,LIB16,LIB32})
* INT config_int(ENUM {LINKSIZE,MATCHLIMIT,PARENSLIMIT,RECURSIONLIMIT}, ENUM {LIB8,LIB16,LIB32})
* regex(STRING, BOOL, BOOL, ENUM {ANYCRLF,UNICODE}, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, STRING, BOOL, INT, BOOL, BOOL, BOOL, BOOL, ENUM {CR,LF,CRLF,ANYCRLF,ANY}, BOOL, BOOL, BOOL, BOOL, BOOL, INT, BOOL, BOOL, BOOL, BOOL)
* BOOL config_bool(ENUM {JIT,STACKRECURSE,UNICODE})
* STRING config_str(ENUM {BSR,JITTARGET,NEWLINE,UNICODE_VERSION,VERSION})
* INT config_int(ENUM {LINKSIZE,MATCHLIMIT,PARENSLIMIT,RECURSIONLIMIT})
* STRING version()
.. _obj_regex:
......@@ -50,7 +50,7 @@ regex
::
new OBJ = regex(STRING pattern, ENUM {LIB8,LIB16,LIB32} lib=0, BOOL allow_empty_class=0, BOOL anchored=0, ENUM {ANYCRLF,UNICODE} bsr=0, BOOL alt_bsux=0, BOOL alt_circumflex=0, BOOL alt_verbnames=0, BOOL caseless=0, BOOL dotall=0, BOOL dollar_endonly=0, BOOL dupnames=0, BOOL extended=0, BOOL firstline=0, STRING locale=0, BOOL match_unset_backref=0, INT max_pattern_len=0, BOOL multiline=0, BOOL never_backslash_c=0, BOOL never_ucp=0, BOOL never_utf=0, ENUM {CR,LF,CRLF,ANYCRLF,ANY} newline=0, BOOL no_auto_capture=0, BOOL no_auto_possess=0, BOOL no_dotstar_anchor=0, BOOL no_start_optimize=0, BOOL no_utf_check=0, INT parens_nest_limit=0, BOOL ucp=0, BOOL ungreedy=0, BOOL use_offset_limit=0, BOOL utf=0)
new OBJ = regex(STRING pattern, BOOL allow_empty_class=0, BOOL anchored=0, ENUM {ANYCRLF,UNICODE} bsr=0, BOOL alt_bsux=0, BOOL alt_circumflex=0, BOOL alt_verbnames=0, BOOL caseless=0, BOOL dotall=0, BOOL dollar_endonly=0, BOOL dupnames=0, BOOL extended=0, BOOL firstline=0, STRING locale=0, BOOL match_unset_backref=0, INT max_pattern_len=0, BOOL multiline=0, BOOL never_backslash_c=0, BOOL never_ucp=0, BOOL never_utf=0, ENUM {CR,LF,CRLF,ANYCRLF,ANY} newline=0, BOOL no_auto_capture=0, BOOL no_auto_possess=0, BOOL no_dotstar_anchor=0, BOOL no_start_optimize=0, BOOL no_utf_check=0, INT parens_nest_limit=0, BOOL ucp=0, BOOL ungreedy=0, BOOL use_offset_limit=0, BOOL utf=0)
# XXX options for dfa_match, jit fast path, start_offset
# XXX option to make saving the match ctx with PRIV_CALL optional
......@@ -70,7 +70,7 @@ config_bool
::
BOOL config_bool(ENUM {JIT,STACKRECURSE,UNICODE}, ENUM {LIB8,LIB16,LIB32} lib=0)
BOOL config_bool(ENUM {JIT,STACKRECURSE,UNICODE})
.. _func_config_str:
......@@ -79,7 +79,7 @@ config_str
::
STRING config_str(ENUM {BSR,JITTARGET,NEWLINE,UNICODE_VERSION,VERSION}, ENUM {LIB8,LIB16,LIB32} lib=0)
STRING config_str(ENUM {BSR,JITTARGET,NEWLINE,UNICODE_VERSION,VERSION})
.. _func_config_int:
......@@ -88,7 +88,7 @@ config_int
::
INT config_int(ENUM {LINKSIZE,MATCHLIMIT,PARENSLIMIT,RECURSIONLIMIT}, ENUM {LIB8,LIB16,LIB32} lib=0)
INT config_int(ENUM {LINKSIZE,MATCHLIMIT,PARENSLIMIT,RECURSIONLIMIT})
.. _func_version:
......
......@@ -89,96 +89,7 @@ if test "x$RST2MAN" = "xno"; then
fi
AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
## Build for all pcre2 libs found via pkg-config, except for those
## excluded with a --without-X configure option.
PKG_CHECK_EXISTS([libpcre2-8], [have_lib8=yes], [have_lib8=no])
PKG_CHECK_EXISTS([libpcre2-16], [have_lib16=yes], [have_lib16=no])
PKG_CHECK_EXISTS([libpcre2-32], [have_lib32=yes], [have_lib32=no])
# Fail if none of the pcre2 libs can be found
AS_IF([test "x$have_lib8" != "xyes"], [
AS_IF([test "x$have_lib16" != "xyes"], [
AS_IF([test "x$have_lib32" != "xyes"],
[AC_MSG_ERROR([Could not find any pcre2 lib via pkg-config])]
)],
)]
)
AC_ARG_WITH([libpcre2-8], [
AS_HELP_STRING([--without-libpcre2-8],
[disable the pcre2 8-bit lib (enabled by default if present)])
])
AC_ARG_WITH([libpcre2-16], [
AS_HELP_STRING([--without-libpcre2-16],
[disable the pcre2 16-bit lib (enabled by default if present)])
])
AC_ARG_WITH([libpcre2-32], [
AS_HELP_STRING([--without-libpcre2-32],
[disable the pcre2 32-bit lib (enabled by default if present)])
])
# Fail if a --with option explicitly chose a lib that is not present
AS_IF([test "x$with_libpcre2_8" = "xyes"], [
AS_IF([test "x$have_lib8" != "xyes"],
[AC_MSG_ERROR([libpcre2-8 not found via pkg-config])]
)]
)
AS_IF([test "x$with_libpcre2_16" = "xyes"], [
AS_IF([test "x$have_lib16" != "xyes"],
[AC_MSG_ERROR([libpcre2-16 not found via pkg-config])]
)]
)
AS_IF([test "x$with_libpcre2_32" = "xyes"], [
AS_IF([test "x$have_lib32" != "xyes"],
[AC_MSG_ERROR([libpcre2-32 not found via pkg-config])]
)]
)
# Set up use of the pcre2 libs
PCRE2_CFLAGS=""
PCRE2_LIBS=""
AS_IF([test "x$have_lib8" != "xno"], [
AS_IF([test "x$with_libpcre2_8" != "xno"], [
PKG_CHECK_MODULES([PCRE2_8], [libpcre2-8])
AC_SUBST([PCRE2_8_CFLAGS])
AC_SUBST([PCRE2_8_LIBS])
PCRE2_CFLAGS=${PCRE2_8_CFLAGS}
PCRE2_LIBS=${PCRE2_8_LIBS}
AC_DEFINE([HAVE_PCRE2_8], [1],
[Define to 1 if the 8-bit pcre2 library is used])
])
])
AS_IF([test "x$have_lib16" != "xno"], [
AS_IF([test "x$with_libpcre2_16" != "xno"], [
PKG_CHECK_MODULES([PCRE2_16], [libpcre2-16])
AC_SUBST([PCRE2_16_CFLAGS])
AC_SUBST([PCRE2_16_LIBS])
PCRE2_CFLAGS="${PCRE2_CFLAGS} ${PCRE2_16_CFLAGS}"
PCRE2_LIBS="${PCRE2_LIBS} ${PCRE2_16_LIBS}"
AC_DEFINE([HAVE_PCRE2_16], [1],
[Define to 1 if the 16-bit pcre2 library is used])
])
])
AS_IF([test "x$have_lib32" != "xno"], [
AS_IF([test "x$with_libpcre2_32" != "xno"], [
PKG_CHECK_MODULES([PCRE2_32], [libpcre2-32])
AC_SUBST([PCRE2_32_CFLAGS])
AC_SUBST([PCRE2_32_LIBS])
PCRE2_CFLAGS="${PCRE2_CFLAGS} ${PCRE2_32_CFLAGS}"
PCRE2_LIBS="${PCRE2_LIBS} ${PCRE2_32_LIBS}"
AC_DEFINE([HAVE_PCRE2_32], [1],
[Define to 1 if the 32-bit pcre2 library is used])
])
])
AS_IF([test -z "$PCRE2_LIBS"], [
AC_MSG_ERROR([You must enable at least one available pcre2 lib])
])
PKG_CHECK_MODULES([PCRE2], [libpcre2-8])
AC_SUBST([PCRE2_CFLAGS])
AC_SUBST([PCRE2_LIBS])
......
......@@ -6,9 +6,7 @@ vmod_LTLIBRARIES = libvmod_pcre2.la
libvmod_pcre2_la_LDFLAGS = -module -export-dynamic -avoid-version -shared
libvmod_pcre2_la_SOURCES = \
vmod_pcre2.c \
vmod_pcre2.h \
pcre2_compat.h
vmod_pcre2.c
nodist_libvmod_pcre2_la_SOURCES = \
vcc_if.c \
......
This diff is collapsed.
......@@ -46,48 +46,3 @@ client c1 {
expect resp.http.parenslimit ~ "^\\d+$"
expect resp.http.recursionlimit ~ "^\\d+$"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.jit = pcre2.config_bool(JIT, lib=LIB8);
set resp.http.stackrecurse = pcre2.config_bool(STACKRECURSE);
set resp.http.unicode = pcre2.config_bool(UNICODE);
set resp.http.bsr = pcre2.config_str(BSR);
set resp.http.jittarget = pcre2.config_str(JITTARGET);
set resp.http.newline = pcre2.config_str(NEWLINE);
set resp.http.unicode-version
= pcre2.config_str(UNICODE_VERSION);
set resp.http.version = pcre2.config_str(VERSION);
set resp.http.linksize = pcre2.config_int(LINKSIZE);
set resp.http.matchlimit = pcre2.config_int(MATCHLIMIT);
set resp.http.parenslimit = pcre2.config_int(PARENSLIMIT);
set resp.http.recursionlimit = pcre2.config_int(RECURSIONLIMIT);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.jit ~ "^(true|false)$"
expect resp.http.stackrecurse ~ "^(true|false)$"
expect resp.http.unicode ~ "^(true|false)$"
expect resp.http.bsr ~ "^(UNICODE|ANYCRLF)$"
expect resp.http.jittarget ~ ".+"
expect resp.http.newline ~ "^(CR|LF|CRLF|ANY|ANYCRLF)$"
expect resp.http.unicode-version ~ ".+"
expect resp.http.version ~ ".+"
expect resp.http.linksize ~ "^\\d+$"
expect resp.http.matchlimit ~ "^\\d+$"
expect resp.http.parenslimit ~ "^\\d+$"
expect resp.http.recursionlimit ~ "^\\d+$"
} -run
This diff is collapsed.
......@@ -17,8 +17,7 @@ DESCRIPTION
This Varnish Module (VMOD) provides access to the PCRE2 regular
expresion library.
$Object regex(STRING pattern, ENUM {LIB8, LIB16, LIB32} lib=0,
BOOL allow_empty_class=0, BOOL anchored=0,
$Object regex(STRING pattern, BOOL allow_empty_class=0, BOOL anchored=0,
ENUM {ANYCRLF, UNICODE} bsr=0, BOOL alt_bsux=0,
BOOL alt_circumflex=0, BOOL alt_verbnames=0, BOOL caseless=0,
BOOL dotall=0, BOOL dollar_endonly=0, BOOL dupnames=0,
......@@ -39,15 +38,13 @@ $Method BOOL .match(PRIV_CALL, PRIV_TASK, STRING, INT len=0, BOOL anchored=0,
BOOL no_jit=0, BOOL no_utf_check = 0,
ENUM {HARD, SOFT} partial=0, INT recursion_limit=0)
$Function BOOL config_bool(ENUM {JIT, STACKRECURSE, UNICODE},
ENUM {LIB8, LIB16, LIB32} lib=0)
$Function BOOL config_bool(ENUM {JIT, STACKRECURSE, UNICODE})
$Function STRING config_str(ENUM {BSR, JITTARGET, NEWLINE,
UNICODE_VERSION, VERSION},
ENUM {LIB8, LIB16, LIB32} lib=0)
$Function STRING config_str(ENUM {BSR, JITTARGET, NEWLINE, UNICODE_VERSION,
VERSION})
$Function INT config_int(ENUM {LINKSIZE, MATCHLIMIT, PARENSLIMIT,
RECURSIONLIMIT}, ENUM {LIB8, LIB16, LIB32} lib=0)
RECURSIONLIMIT})
$Function STRING version()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment