Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1ad1cd3
Enhance array and URL encoding support in queryfilter and introduce g…
stankolubomir Mar 25, 2026
663f987
refactor: Separate build jobs for Linux, macOS, and FreeBSD, introduc…
stankolubomir Mar 25, 2026
7c73e83
feat: Add Varnish 8.x compatibility and update build/test infrastruct…
stankolubomir Mar 25, 2026
c8af2e8
Fix freebsd build
stankolubomir Mar 25, 2026
8fb4372
build: update cross-platform-actions/action to v0.32.0
stankolubomir Mar 25, 2026
b4cf059
build: update Varnish package to varnish7
stankolubomir Mar 25, 2026
d3ef3ab
build: Add python3 as a dependency to the build workflow.
stankolubomir Mar 25, 2026
475e094
feat: Refine query parameter filtering to prevent plain filters from …
stankolubomir Mar 25, 2026
beee6d4
Fix tests
stankolubomir Mar 25, 2026
3a6c985
Add changelog
Mar 31, 2026
b5c9e4a
Merge branch 'main' into url_encoding
Mar 31, 2026
1b2d1ab
Update readme
Mar 31, 2026
e2eec0c
Add MacOSx support only for v8
Mar 31, 2026
9caa997
Disable macOS for now
Mar 31, 2026
a15a3ca
Refactor build pipeline to support all distros for all supported varn…
Mar 31, 2026
e6eda01
build: add docutils and py311-docutils to CI build dependencies
Mar 31, 2026
60ee511
build: add sphinx-doc to macOS and FreeBSD CI dependencies
Mar 31, 2026
ba13815
fix: add sudo to install command and update PKG_CONFIG_PATH for build…
Mar 31, 2026
8970700
ci: exclude Varnish 7.7.3 from macOS builds due to missing endian.h h…
Mar 31, 2026
a70904d
chore: force Node.js 24 for GitHub Actions to prepare for future depr…
Mar 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Build

on:
pull_request:
branches:
- main
paths-ignore:
- "**/*.md"

env:
# cross-platform-actions/action@v0.32.0 runs on Node.js 20 which is deprecated.
# Opt into Node.js 24 now ahead of the June 2026 forced migration.
# Remove once a new cross-platform-actions release with Node.js 24 support is available.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
build:
strategy:
fail-fast: false
matrix:
varnish: ["7.6.5", "7.7.3", "8.0.1"]
platform:
- { name: Ubuntu, runner: ubuntu-latest }
- { name: Rocky, runner: ubuntu-latest, container: rockylinux:9 }
- { name: macOS, runner: macos-latest }
- { name: FreeBSD, runner: ubuntu-latest }
exclude:
# Varnish 7.7.3 uses endian.h which does not exist on macOS (uses machine/endian.h instead).
# Upstream issue: https://github.com/varnishcache/varnish-cache/issues/4299
- varnish: "7.7.3"
platform: { name: macOS, runner: macos-latest }
runs-on: ${{ matrix.platform.runner }}
container: ${{ matrix.platform.container }}
name: ${{ matrix.platform.name }} / Varnish ${{ matrix.varnish }}
steps:
- uses: actions/checkout@v6

- name: Install dependencies (Ubuntu)
if: "matrix.platform.name == 'Ubuntu'"
run: |
VERSION_SHORT=$(echo "${{ matrix.varnish }}" | cut -d. -f1,2 | tr -d '.')
curl -s "https://packagecloud.io/install/repositories/varnishcache/varnish${VERSION_SHORT}/script.deb.sh" | sudo bash
docker run --rm -v /tmp/pcre3:/out debian:bookworm-slim \
bash -c 'apt-get update -qq && apt-get download -q \
libpcre3 libpcre3-dev libpcre16-3 libpcre32-3 libpcrecpp0v5 \
&& mv *.deb /out/'
sudo dpkg -i /tmp/pcre3/*.deb
sudo apt-get install -y \
varnish-dev \
autoconf \
automake \
libtool \
pkg-config \
python3-docutils

- name: Install dependencies (Rocky Linux)
if: "matrix.platform.name == 'Rocky'"
run: |
VERSION_SHORT=$(echo "${{ matrix.varnish }}" | cut -d. -f1,2 | tr -d '.')
dnf install -y epel-release
curl -s "https://packagecloud.io/install/repositories/varnishcache/varnish${VERSION_SHORT}/script.rpm.sh" | bash
dnf install -y \
varnish-devel \
autoconf \
automake \
libtool \
pkgconfig \
pcre-devel \
python3-docutils

- name: Install dependencies (macOS)
if: "matrix.platform.name == 'macOS'"
run: |
brew install \
autoconf \
automake \
libtool \
pkg-config \
pcre \
pcre2 \
docutils \
sphinx-doc
echo "$(brew --prefix sphinx-doc)/bin" >> "$GITHUB_PATH"

- name: Build and install Varnish from source
if: "matrix.platform.name == 'macOS'"
run: |
git clone --recursive \
--branch varnish-${{ matrix.varnish }} \
https://code.vinyl-cache.org/vinyl-cache/vinyl-cache.git \
/tmp/varnish-src
cd /tmp/varnish-src
./autogen.sh
./configure --prefix=/usr/local
make
sudo make install

- name: Build and test
if: "matrix.platform.name != 'FreeBSD'"
run: |
./autogen.sh
./configure && make && make check

- name: Install dependencies (FreeBSD)
if: "matrix.platform.name == 'FreeBSD'"
uses: cross-platform-actions/action@v0.32.0
with:
operating_system: freebsd
version: "14.2"
shutdown_vm: false
sync_files: runner-to-vm
run: |
sudo pkg install -y \
autoconf \
automake \
libtool \
pkgconf \
pcre \
pcre2 \
python3 \
py311-docutils \
py311-sphinx \
git

- name: Build and install Varnish from source (FreeBSD)
if: "matrix.platform.name == 'FreeBSD'"
uses: cross-platform-actions/action@v0.32.0
with:
operating_system: freebsd
version: "14.2"
shutdown_vm: false
sync_files: false
run: |
git clone --recursive \
--branch varnish-${{ matrix.varnish }} \
https://code.vinyl-cache.org/vinyl-cache/vinyl-cache.git \
/tmp/varnish-src
cd /tmp/varnish-src
./autogen.sh
./configure --prefix=/usr/local
make
sudo make install

- name: Build and test (FreeBSD)
if: "matrix.platform.name == 'FreeBSD'"
uses: cross-platform-actions/action@v0.32.0
with:
operating_system: freebsd
version: "14.2"
sync_files: false
run: |
./autogen.sh
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure && make && make check
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests

on:
pull_request:
branches:
- main
paths-ignore:
- "**/*.md"

jobs:
docker-tests:
runs-on: ubuntu-latest
strategy:
matrix:
varnish_version:
- "6.0.17"
- "7.6.5"
- "7.7.3"
- "8.0.1"
name: Varnish ${{ matrix.varnish_version }}
steps:
- uses: actions/checkout@v6

- name: Build and test
run: |
docker build . \
--build-arg "VARNISH_VERSION=${{ matrix.varnish_version }}" \
-t "libvmod-queryfilter:local-${{ matrix.varnish_version }}"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ vmod_queryfilter.3

# Things not to ignore
!m4/ax_*

# AI - commit skills (except gitnexus), ignore everything else
.claude/*
!.claude/skills/
.claude/skills/gitnexus/
.gitnexus/
39 changes: 30 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
v1.0.1 2022/0109:
# Changelog

## [Unreleased] — Petit Press Fork

> This fork is maintained by [Petit Press, a.s.](https://github.com/petitpress/libvmod-queryfilter).
> Forked from [nytimes/libvmod-queryfilter](https://github.com/nytimes/libvmod-queryfilter) (last upstream release: v1.0.1, 2023-01-09).

### Features
- Add support for indexed array notation (`item[0]=value`, `item[1]=value`) in addition to traditional (`item[]=value`)
- Add URL decoding of parameter names before matching: percent-encoding (`%5B` → `[`) and plus-encoding (`+` → space); original encoding is preserved verbatim in the output URI
- Add Varnish 8.x API compatibility
- Fix: plain filter (e.g. `item`) no longer matches array parameters (e.g. `item[]`) when arrays are enabled
- Fix: correct handling of long URL-encoded parameter names

### Build & CI
- Introduce GitHub Actions workflows with build matrix for Linux, macOS, and FreeBSD
- Add Varnish version matrix for Linux builds (covering Varnish 6.x, 7.x, and 8.x)
- Add python3 as a build dependency

---

## Upstream History (nytimes/libvmod-queryfilter)

> Original changelog from https://github.com/nytimes/libvmod-queryfilter.
> Maintained until 2023 by The New York Times Company and contributors.

v1.0.1 2022/01/09:
-----------------

### Updates to fix issue #6:
Expand Down Expand Up @@ -59,7 +85,6 @@ v0.1.0 2015/07/09
re-ordered)
- Use md2man (when available) to generate manpage for make dist


v0.0.4 2015/02/06
-----------------
Remove a kludge and save a few bytes of WS on success.
Expand All @@ -69,13 +94,11 @@ v0.0.3 2015/02/03
### Bugfixes
Check for empty query parameter values.


v0.0.2 2015/01/29
-----------------
### Bugfixes
Removed linked list node removal to patch bug where match search could run off the end of the list.


v0.0.1 2015/01/27
-----------------
### Optimizations
Expand All @@ -85,15 +108,13 @@ superfluous node traversal.
### Bugfixes
#### Single query param results in filtering error
The following config:

set req.url = queryfilter.filterparams(req.url, "q,tag");

Was failing for URI's containing only one of the query terms, e.g.:

curl "http://my_host/?q=1"


v0.0.0 2015/01/26
-----------------
Initial version.

73 changes: 43 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,48 @@
# vmod-queryfilter-dev-base: tooling required to build varnish + vmod
#-------------------------------------------------------------------------------

FROM gcc:latest AS vmod-queryfilter-dev-base
#-------------------------------------------------------------------------------
# pcre3-debs: fetch libpcre3/libpcre3-dev from bookworm (dropped in trixie)
#-------------------------------------------------------------------------------
FROM debian:bookworm-slim AS pcre3-debs

RUN apt-get update && \
apt-get download libpcre3 libpcre3-dev libpcre16-3 libpcre32-3 libpcrecpp0v5

#-------------------------------------------------------------------------------
# vmod-queryfilter-dev-base: tooling required to build varnish + vmod
#-------------------------------------------------------------------------------
FROM gcc:14 AS vmod-queryfilter-dev-base

RUN apt-get update
RUN apt-get install -y \
pip
RUN pip install \
docutils \
sphinx
COPY --from=pcre3-debs /*.deb /tmp/pcre3/
RUN apt-get update && \
apt-get install -y \
git \
python3-docutils \
python3-sphinx \
pkg-config && \
dpkg -i /tmp/pcre3/*.deb || apt-get install -f -y && \
rm -rf /tmp/pcre3

#-------------------------------------------------------------------------------
# vmod-queryfilter-varnish: fresh varnish install from source
#-------------------------------------------------------------------------------
ARG VARNISH_VERSION=7.2.1
ARG VARNISH_VERSION=8.0.1
FROM vmod-queryfilter-dev-base AS vmod-queryfilter-varnish
ENV VARNISH_VERSION=${VARNISH_VERSION}
ENV VARNISHSRC=/src/varnish-cache-varnish-${VARNISH_VERSION}
ENV CFLAGS="-Wno-error=format-overflow"

# Download and prep source:
RUN mkdir -p /src \
&& cd /src \
&& wget https://github.com/varnishcache/varnish-cache/archive/refs/tags/varnish-${VARNISH_VERSION}.tar.gz \
&& tar -xzf varnish-${VARNISH_VERSION}.tar.gz \
&& cd varnish-cache-varnish-${VARNISH_VERSION} \
&& ./autogen.sh \
&& ./configure \
--prefix=/usr/local \
&& make \
&& make install
ENV VARNISHSRC=/src/varnish-${VARNISH_VERSION}

# Clone source with submodules (archive tarballs omit them, breaking configure):
RUN git clone --recursive \
--branch varnish-${VARNISH_VERSION} \
https://code.vinyl-cache.org/vinyl-cache/vinyl-cache.git \
${VARNISHSRC} && \
cd ${VARNISHSRC} && \
./autogen.sh && \
./configure \
--prefix=/usr/local && \
make CFLAGS="-Wno-error=format-overflow" && \
make install

#-------------------------------------------------------------------------------
# vmod-queryfilter-vmod: build and test the vmod
Expand All @@ -45,12 +58,12 @@ FROM vmod-queryfilter-varnish AS vmod-queryfilter-test

COPY . /src/libvmod-queryfilter

RUN cd /src/libvmod-queryfilter \
&& ./autogen.sh
RUN cd /src/libvmod-queryfilter && \
./autogen.sh

RUN mkdir -p /src/build \
&& cd /src/build \
&& ../libvmod-queryfilter/configure \
--prefix=/usr/local \
&& make \
&& make check
RUN mkdir -p /src/build && \
cd /src/build && \
../libvmod-queryfilter/configure \
--prefix=/usr/local && \
make && \
make check
Loading
Loading