1
0

downgrade to kirby v3

This commit is contained in:
Philip Wagner
2024-09-01 10:47:15 +02:00
parent a4b2aece7b
commit af86acb7a1
1085 changed files with 54743 additions and 65042 deletions

View File

@@ -0,0 +1,44 @@
name: "testing"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Cache PHP dependencies
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-
- name: Install dependencies
run: composer install
- name: Tests
run: composer test

View File

@@ -0,0 +1,59 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.8] - 2023-11-29
### Fixed
- libxml internal buffer leak [#5]
## [0.1.7] - 2022-12-17
### Added
- Support for PHP 8.2 [#4].
### Changed
- Use GitHub Workflows for testing.
## [0.1.6] - 2020-11-19
### Added
- Added a second argument to `parse` and `parseFragment` to specify the encoding instead autodetect [#2] [#3].
## [0.1.5] - 2020-08-31
### Fixed
- Support for PHP 8 [#1].
## [0.1.4] - 2019-12-15
### Fixed
- Changed the way to handle different encodings detecting the <meta charset> and <meta http-equiv> elements
## [0.1.3] - 2019-07-20
### Fixed
- UTF-8 enconding issues
## [0.1.2] - 2019-05-25
### Fixed
- Improved encoding detection
## [0.1.1] - 2019-04-21
### Fixed
- `parseFragment` was returning a fragment containing only the first element
## [0.1.0] - 2019-04-21
First version
[#1]: https://github.com/oscarotero/html-parser/issues/1
[#2]: https://github.com/oscarotero/html-parser/issues/2
[#3]: https://github.com/oscarotero/html-parser/issues/3
[#4]: https://github.com/oscarotero/html-parser/issues/4
[#5]: https://github.com/oscarotero/html-parser/issues/5
[0.1.8]: https://github.com/oscarotero/html-parser/compare/v0.1.7...v0.1.8
[0.1.7]: https://github.com/oscarotero/html-parser/compare/v0.1.6...v0.1.7
[0.1.6]: https://github.com/oscarotero/html-parser/compare/v0.1.5...v0.1.6
[0.1.5]: https://github.com/oscarotero/html-parser/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/oscarotero/html-parser/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/oscarotero/html-parser/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/oscarotero/html-parser/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/oscarotero/html-parser/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/oscarotero/html-parser/releases/tag/v0.1.0

21
vendor/oscarotero/html-parser/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Oscar Otero
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

25
vendor/oscarotero/html-parser/README.md vendored Normal file
View File

@@ -0,0 +1,25 @@
# HTML parser
Simple utility to parse html strings to DOMDocument.
```sh
composer require oscarotero/html-parser
```
## Usage
```php
use HtmlParser\Parser;
$html = '<html><head></head><body>Hello world</body></html>';
//Convert a string to a DOMDocument
$document = Parser::parse($html);
//Convert a string to a DOMDocumentFragment
$fragment = Parser::parseFragment('<p>Hello world</p>');
//Convert a DOMDocument or DOMDocumentFragment to a string
echo Parser::stringify($document);
echo Parser::stringify($fragment);
```

View File

@@ -0,0 +1,41 @@
{
"name": "oscarotero/html-parser",
"type": "library",
"description": "Parse html strings to DOMDocument",
"keywords": ["html", "parser", "dom"],
"homepage": "https://github.com/oscarotero/html-parser",
"license": "MIT",
"authors": [
{
"name": "Oscar Otero",
"email": "oom@oscarotero.com",
"homepage": "http://oscarotero.com",
"role": "Developer"
}
],
"support": {
"email": "oom@oscarotero.com",
"issues": "https://github.com/oscarotero/html-parser/issues"
},
"require": {
"php": "^7.2 || ^8"
},
"autoload": {
"psr-4": {
"HtmlParser\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"HtmlParser\\Tests\\": "tests"
}
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"friendsofphp/php-cs-fixer": "^2.11"
},
"scripts": {
"test": "phpunit",
"cs-fix": "php-cs-fixer fix ."
}
}

View File

@@ -0,0 +1,99 @@
<?php
declare(strict_types = 1);
namespace HtmlParser;
use Exception;
use DOMNode;
use DOMDocument;
use DOMDocumentFragment;
use SimpleXMLElement;
use DOMXPath;
class Parser
{
public static function stringify(DOMNode $node): string
{
if ($node instanceof DOMDocument) {
return $node->saveHTML($node);
}
return $node->ownerDocument->saveHTML($node);
}
public static function parse(string $html, ?string $encoding = null): DOMDocument
{
$detected = $encoding ?? mb_detect_encoding($html);
if ($detected) {
$html = mb_encode_numericentity($html, [0x80, 0xFFFFFF, 0, -1], $detected);
}
$document = self::createDOMDocument($html);
$xpath = new DOMXPath($document);
$charset = $xpath->query('.//meta[@charset]')->item(0);
$httpEquiv = $xpath->query('.//meta[@http-equiv]')->item(0);
if ($charset || $httpEquiv) {
$charset = $charset ? self::stringify($charset) : null;
$httpEquiv = $httpEquiv ? self::stringify($httpEquiv) : null;
$html = preg_replace(
'/<head[^>]*>/',
'<head>'.$charset.$httpEquiv,
$html
);
return self::createDOMDocument($html);
}
return $document;
}
public static function parseFragment(string $html, ?string $encoding = null): DOMDocumentFragment
{
$html = "<html><head></head><body>{$html}</body></html>";
$document = static::parse($html, $encoding);
$fragment = $document->createDocumentFragment();
$body = $document->getElementsByTagName('body')->item(0);
$nodes = [];
foreach ($body->childNodes as $node) {
$nodes[] = $node;
}
foreach ($nodes as $node) {
$fragment->appendChild($node);
}
return $fragment;
}
private static function createDOMDocument(string $code): DOMDocument
{
$errors = libxml_use_internal_errors(true);
// Enabled by default in PHP 8
if (PHP_MAJOR_VERSION < 8) {
$entities = libxml_disable_entity_loader(true);
}
$document = new DOMDocument();
$document->loadHTML($code);
libxml_use_internal_errors($errors);
if (PHP_MAJOR_VERSION < 8) {
libxml_disable_entity_loader($entities);
}
if (libxml_get_last_error() !== false) {
libxml_clear_errors();
}
return $document;
}
}