diff --git a/.github/workflows/coding-standard.yml b/.github/workflows/coding-standard.yml index 29e2b44..0bc15c3 100644 --- a/.github/workflows/coding-standard.yml +++ b/.github/workflows/coding-standard.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 6a450c2..4347abf 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/unit-testing.yml b/.github/workflows/unit-testing.yml index be8b87d..5e99e9a 100644 --- a/.github/workflows/unit-testing.yml +++ b/.github/workflows/unit-testing.yml @@ -4,18 +4,21 @@ on: [ pull_request ] jobs: phpunit: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os || 'ubuntu-latest' }} strategy: matrix: php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] include: - - php: '8.3' + # libxml2 2.14+ (ubuntu-26.04 onwards) parses HTML as HTML5, which skips the tests for + # libxml's older HTML parser, so the coverage job stays on a runner that still has it. + - php-versions: '8.3' + os: ubuntu-24.04 report: true name: PHP ${{ matrix.php-versions }} PHPUnit Test steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -43,7 +46,7 @@ jobs: - name: Check Code Coverage if: ${{ matrix.report }} - uses: codecov/codecov-action@v5 + uses: codecov/codecov-action@v7 with: directory: ./coverage/ token: ${{ secrets.CODECOV_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c9c4dc6..b953986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ QueryPath Changelog - Rewrite the cURL example against the PubMed E-utilities API. MusicBrainz throttles by IP address, which made the example unusable from any shared address - Add `composer run test:examples` (and `test:examples:network`) to run the examples locally - Fix processing instructions gaining an extra `?` each time an HTML-parsed document was serialized, so `` came back out of `html()`, `innerHTML()`, `innerXML()`, `innerXHTML()`, `xml()`, `html5()`, `innerHTML5()`, and `writeXML()` as ``. libxml's HTML parser keeps the closing `?` as part of the node's data, unlike its XML parser and the Masterminds HTML5 parser, so QueryPath now strips it on load. `DOMProcessingInstruction::$data` consequently no longer has a stray `?` on the end for documents read with `htmlqp()` or `qp()` on an `.html` file. Note that this normalisation applies only to documents QueryPath parses itself, and that taking the underlying `DOMDocument` out of QueryPath and calling libxml's own `saveHTML()` on it will emit `` without the terminator, since libxml's HTML serializer never adds one +- With libxml2 2.14+, `htmlqp()` parses `` as a comment (``) and no longer throws `QueryPath\ParseException` on malformed HTML. Use `html5qp()` to keep processing instructions - Add `QueryPath\Document`, a `DOMDocument` subclass QueryPath parses into. The type is how QueryPath records that a document's processing instruction data does not carry the closing `?`, which cannot be determined by inspecting the document afterwards. It travels with the document, so every route to a second `DOMQuery` over one document -- iteration, `add()`, `remove()`, `replaceAll()`, `branch()`, `QueryPath::with()`, and the bundled extensions -- serializes it correctly. A `DOMDocument` supplied by the caller is a plain `DOMDocument`, makes no such promise, and is still serialized exactly as it was handed over - Fix fatal error when running a CSS selector against a match set that contains non-element nodes (text, comment, CDATA or processing instruction), as `contents()` returns. Those nodes now simply do not match, instead of calling element-only DOM methods on them - Fix `find('a > b')` throwing a `TypeError` when the left-hand side matched the root element, whose parent is the document rather than an element diff --git a/tests/Issues/Issue65ParserIndependentTest.php b/tests/Issues/Issue65ParserIndependentTest.php new file mode 100644 index 0000000..487796e --- /dev/null +++ b/tests/Issues/Issue65ParserIndependentTest.php @@ -0,0 +1,107 @@ +