1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Verify bundled PCRE2 in CI

Closes GH-20354
This commit is contained in:
Michael Voříšek
2025-11-12 18:10:21 +01:00
committed by Ilija Tovilo
parent b9562adff6
commit 7db647dd99
5 changed files with 92 additions and 11 deletions

View File

@@ -13,5 +13,4 @@ runs:
ext/tokenizer/tokenizer_data_gen.php
build/gen_stub.php -f --generate-optimizer-info --verify
ext/phar/makestub.php
# Use the -a flag for a bug in git 2.46.0, which doesn't consider changed -diff files.
git add . -N && git diff -a --exit-code
.github/scripts/test-directory-unchanged.sh .

32
.github/scripts/download-bundled/pcre2.sh vendored Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
set -ex
cd "$(dirname "$0")/../../.."
revision=refs/tags/pcre2-10.44
git clone --depth 1 --recurse-submodules --revision="$revision" https://github.com/PCRE2Project/pcre2.git /tmp/php-src-bundled/pcre2
rm -rf ext/pcre/pcre2lib
cp -R /tmp/php-src-bundled/pcre2/src ext/pcre/pcre2lib
cd ext/pcre/pcre2lib
# remove unneeded files
rm config.h.generic
rm pcre2.h.in
rm pcre2_dftables.c
rm pcre2_fuzzsupport.c
rm pcre2_jit_test.c
rm pcre2demo.c
rm pcre2grep.c
rm pcre2posix.c
rm pcre2posix.h
rm pcre2posix_test.c
rm pcre2test.c
# move renamed files
mv pcre2.h.generic pcre2.h
mv pcre2_chartables.c.dist pcre2_chartables.c
# add extra files
git restore config.h # based on config.h.generic but with many changes

13
.github/scripts/test-directory-unchanged.sh vendored Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
set -ex
cd "$(dirname "$0")/../../$1"
# notify git about untracked (except ignored) files
git add -N .
# display overview of changed files
git status .
# display diff of working directory vs HEAD commit and set exit code
git diff -a --exit-code HEAD .

View File

@@ -0,0 +1,43 @@
name: Verify Bundled Files
on:
push:
paths: &paths
- '.github/scripts/download-bundled/pcre2.sh'
- 'ext/pcre/pcre2lib/**'
pull_request:
paths: *paths
schedule:
- cron: "0 1 * * *"
workflow_dispatch: ~
permissions:
contents: read
jobs:
VERIFY_BUNDLED_FILES:
name: Verify Bundled Files
runs-on: ubuntu-24.04
steps:
- name: git checkout
uses: actions/checkout@v5
- name: Detect changed files
uses: dorny/paths-filter@v3
id: changes
with:
base: master
filters: |
pcre2:
- '.github/scripts/download-bundled/pcre2.sh'
- 'ext/pcre/pcre2lib/**'
- name: PCRE2
if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
run: |
echo "::group::Download"
.github/scripts/download-bundled/pcre2.sh
echo "::endgroup::"
echo "::group::Verify files"
.github/scripts/test-directory-unchanged.sh ext/pcre/pcre2lib
echo "::endgroup::"

View File

@@ -5,7 +5,8 @@
/* This file was automatically written by the pcre2_dftables auxiliary
program. It contains character tables that are used when no external
tables are passed to PCRE2 by the application that calls it. The tables
are used only for characters whose code values are less than 256. */
are used only for characters whose code values are less than 256, and
only relevant if not in UCP mode. */
/* This set of tables was written in the C locale. */
@@ -18,13 +19,6 @@ PCRE2 is configured with --enable-rebuild-chartables. However, you can run
pcre2_dftables manually with the -L option to build tables using the LC_ALL
locale. */
/* The following #include is present because without it gcc 4.x may remove
the array definition from the final binary if PCRE2 is built into a static
library and dead code stripping is activated. This leads to link errors.
Pulling in the header ensures that the array gets flagged as "someone
outside this compilation unit might reference this" and so it will always
be supplied to the linker. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -163,7 +157,7 @@ graph, print, punct, and cntrl. Other classes are built from combinations. */
0x02 letter
0x04 lower case letter
0x08 decimal digit
0x10 alphanumeric or '_'
0x10 word (alphanumeric or '_')
*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */