This commit is contained in:
Javier Casares 2026-11-04 17:27:19 +00:00
commit 121c35737d
85 changed files with 1398 additions and 2198 deletions

View file

@ -1,5 +1,47 @@
== Changelog ==
= 1.2.3 =
_Release date: 2026-11-04_
**Highlights**
* Tested up to WordPress 7.2 and PHP 8.6; real minimums re-verified (WordPress 4.2, PHP 8.0)
* Admin menu icon replaced with an inline SVG (WordPress core is moving from the Dashicons font to SVG in 7.2 — Trac #65089 / PR #12270)
* PHPStan raised to level 10 — the maximum — with no baseline
**Security**
* No security findings in this release; `composer audit` clean for both production and dev dependency sets
**Changed**
* Admin menu icon switched from `dashicons-media-document` to a base64 SVG data URI. Core has special-cased `data:image/svg+xml;base64,` menu icons since WordPress 4.2, so the icon renders identically on every supported version and does not depend on the new WordPress-7.2-only `wp_get_icon()` API
* PHPStan static analysis raised from level 9 to level 10 (the maximum, no baseline): the `robotstxt_docmd_input_string()` / `robotstxt_docmd_input_int()` helpers now document their `$input` parameter as `array<mixed>` (superglobals and `get_option()` returns carry no string-key guarantee), `WP_Query::$posts` is type-narrowed with `is_array()` (wordpress-stubs 7.1 types it as nullable), `global $wpdb` is type-narrowed with an `instanceof wpdb` guard, and post-type label output is narrowed to string
* The transient-cleanup queries (debug "Clear All Plugin Caches" and `uninstall.php` prefix deletes) now build LIKE patterns with the `esc_sql( $wpdb->esc_like( ... ) )` chain documented in `wpdb::esc_like()`, instead of `$wpdb->prepare()`. Reason: wordpress-stubs types `wpdb::prepare()`'s query parameter as `literal-string`, which table-name interpolation can never satisfy; the escaping chain offers equivalent safety for bulk prefix deletes. Deliberate, documented exception to the AGENTS-security "prepare() for all custom SQL" checklist item
* `robotstxt_docmd_get_all_mappings()` iterates a narrowed copy of `WP_Query::$posts` (nullable in the WordPress 7.1 stubs)
**Dependencies**
* league/commonmark 2.10.0 → 2.10.7 (production; no known CVEs). phpstan 2.2.9 → 2.3.5, szepeviktor/phpstan-wordpress 2.0.3 → 2.0.4, php-stubs/wordpress-stubs 6.9.4 → 7.1.2, phpunit 9.6.36 → 9.6.38 (dev only)
* Composer platform pin added at `8.0.99` (the declared PHP floor). The unpinned update had promoted nette/schema 1.4.0 (PHP 8.1-only syntax on the Markdown-conversion autoload path) and nette/utils 4.1.6 (PHP 8.2+) into the production vendor tree — a fatal error on PHP 8.0/8.1 sites caught by the 1.2.3 pre-deploy audit (docs/audit-pre-deploy-1.2.3.md). With the pin the resolver ships nette/schema 1.2.5, nette/utils 4.0.11, and symfony/deprecation-contracts 3.0.2 — every shipped package supports PHP 8.0; conversion verified empirically
* `bin/preflight.sh` section 6 now builds the production vendor in a throwaway /tmp copy and fails unless the composer platform pin matches the header's `Requires PHP` and the production vendor installs under that pin
**Compatibility**
* WordPress: 4.2 - 7.2 (floor re-verified with WP-Compat; smoke-tested on WordPress 7.2-beta4 / PHP 8.6)
* PHP: 8.0 - 8.6 (floor re-verified with PHPCompatibility 5.6-8.6 full-range scan; binding 8.0 constraints: union return types, `str_starts_with()` / `str_contains()`, `mixed` parameter type)
* MariaDB: 11.4 or newer (no DB changes in this release)
**Tests**
* PHP Coding Standards: PHPCS 3.13.6 with WordPress-Core, WordPress-Docs, WordPress-Extra (WPCS 3.4.1) — 0 errors
* PHPStan: level 10 (maximum), 0 errors, no baseline (phpstan 2.3.5 + phpstan-wordpress 2.0.4, stubs 7.1.2)
* PHPCompatibility: 10.0.0-alpha2 — PHP 8.0-8.6 validated (full-range scan 5.6-8.6)
* WP-Compat: 1.5.0 — WordPress 4.2 floor validated (`wp_delete_file()` is the oldest API used)
* PHPUnit: 23 tests pass (17 plugin header tests + 6 Manager-detection tests)
* Manual testing: WordPress 7.2-beta4 single site, PHP 8.6.0RC3 — plugin active, mappings list, debug helpers, and admin menu verified; debug.log clean
= 1.2.2 =
_Release date: 2026-08-24_

View file

@ -2,9 +2,9 @@
Contributors: robotstxt, javiercasares
Tags: github, documentation, markdown, sync, automation
Requires at least: 4.2
Tested up to: 7.1
Tested up to: 7.2
Requires PHP: 8.0
Stable tag: 1.2.2
Stable tag: 1.2.3
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@ -182,13 +182,35 @@ Then go to Documentation → Settings, and you'll see a "Debug Tools" section at
== Compatibility ==
* WordPress: 4.2 - 7.1
* PHP: 8.0 - 8.5
* WordPress: 4.2 - 7.2
* PHP: 8.0 - 8.6
== Changelog ==
For the complete changelog, see [changelog.txt](https://www.robotstxt.software/plugins/robotstxt-documentation-markdown/).
= 1.2.3 - 2026-11-04 =
**Changed**
* Admin menu icon switched from the `dashicons-media-document` font glyph to an inline SVG (base64 data URI) — crisp at any resolution and aligned with the WordPress move from Dashicons to SVG icons (WordPress 7.2 / Trac #65089). Renders identically on every supported WordPress version (4.2 – 7.2); no dependency on the new WP 7.2-only `wp_get_icon()` API
* PHPStan static analysis raised from level 9 to level 10 (the maximum, no baseline): `$_POST`/`$_GET` input helpers now documented as accepting `array<mixed>`, `WP_Query::$posts` and `global $wpdb` type-narrowed, post-type labels narrowed to string
* The two transient-cleanup queries (debug "Clear All Plugin Caches" and uninstall) now escape LIKE patterns with the `esc_sql( $wpdb->esc_like( ... ) )` chain documented in `wpdb::esc_like()`, instead of `$wpdb->prepare()` — equivalent safety for bulk prefix deletes
* `composer update`: league/commonmark 2.10.0 → 2.10.7 (production, no known CVEs); phpstan 2.3.5, wordpress-stubs 7.1.2 (dev). Composer platform pin added at the PHP 8.0 floor so the shipped vendor tree can never require a newer PHP than declared (`nette/schema` 1.4.0 / `nette/utils` 4.1.6 needed PHP 8.1/8.2; the pin ships 1.2.5 / 4.0.11 instead). `composer audit` clean
**Compatibility**
* WordPress: 4.2 - 7.2 (floor re-verified with WP-Compat; smoke-tested on WordPress 7.2-beta4)
* PHP: 8.0 - 8.6 (floor re-verified with PHPCompatibility 5.6-8.6 full-range scan)
**Tests**
* PHP Coding Standards: PHPCS with WordPress-Core, WordPress-Docs, WordPress-Extra — 0 errors
* PHPStan: level 10 (maximum), 0 errors, no baseline
* PHPCompatibility: PHP 8.0-8.6 validated (full-range scan 5.6-8.6)
* WP-Compat: WordPress 4.2 floor validated
* PHPUnit: 23 tests pass (17 plugin header tests + 6 Manager-detection tests)
= 1.2.2 - 2026-08-24 =
**Changed**
@ -227,35 +249,15 @@ For the complete changelog, see [changelog.txt](https://www.robotstxt.software/p
* Spanish (es_ES) and Catalan (ca): 10 missing strings from 1.2.0 added, plus the new Manager notice
= 1.2.0 - 2026-08-07 =
= Previous versions =
**Added**
* **Title from H1:** the synced post title is now taken from the first `# H1` in the Markdown (inline formatting stripped), with the H1 removed from the body to avoid a duplicate heading. Falls back to the filename-derived title when no H1 is present
* **Internal link translation:** repo-relative Markdown links (e.g. `./api.md`, `../README.md`) are rewritten to the permalink of the matching mapped WordPress content. External, `mailto:`, and anchor links are left untouched; links with no matching mapping keep their original URL
* **Repository image sideloading:** images referenced in the Markdown are downloaded from the repository, added to the Media Library, and their references replaced with the attachment URL. Already-imported images are reused on subsequent syncs (tracked per post); removed images are kept in the Media Library (non-destructive)
**Security**
* Patched CVE-2026-71478 (and advisory GHSA-2q4p-g7hv-5rgv) in league/commonmark — an unsafe-link filter bypass that could defeat `allow_unsafe_links: false`. Updated league/commonmark 2.8.2 → 2.9.0
* GitHub token encryption now derives its AES-256 key with HKDF-SHA256 from `wp_salt('auth')` instead of using the salt directly; existing tokens are migrated transparently to the new `v2:` format on first decrypt (covers the cron path too)
* Discover Files "Refresh from GitHub" action is now nonce-protected — previously a crafted link could force an unrequested GitHub API call (CSRF)
* GitHub API request paths are now `rawurlencode()`d (defensive hardening)
* Sideloaded images are validated by extension (jpg, jpeg, png, gif, webp) and size (< 10 MB) before storage; SVG is intentionally excluded
**Fixed**
* "Using cached data / fetching fresh data" indicator on Discover Files now reflects reality — it always showed "cached" because the cache was tested after being populated
* `target_post_type` is now validated against registered public post types on save, falling back to `page` (prevents saving an unregistered or internal type)
* Debug action dispatch refactored into a single `switch`, each case retaining its `check_admin_referer()` check, to reduce the chance of a missing nonce check
**Changed**
* Inline `onclick` confirm on Delete replaced with a `data-confirm` attribute + delegated handler (CSP-friendlier, less fragile)
* Add Mapping "existing content" dropdown now queries only public post types (excludes attachments and the internal mapping CPT) with `no_found_rows` for better performance on large sites
If you want to see the full changelog, visit the [changelog.txt](https://www.robotstxt.software/plugins/robotstxt-documentation-markdown/) file.
== Upgrade Notice ==
= 1.2.3 =
Tested up to WordPress 7.2 and PHP 8.6. New SVG admin menu icon; no settings or data changes are needed.
= 1.2.2 =
Manager (by ROBOTSTXT) detection updated: now uses the ROBOTSTXT_MANAGER_NOTICED presence constant (Manager 1.6.2+) with a fallback for older Manager versions.

View file

@ -230,10 +230,12 @@ function robotstxt_docmd_get_status_badge( string $status ): string {
* Provides PHPStan level 9 compliant type-narrowing for superglobal access.
*
* @since 1.0.1
* @since 1.2.3 Parameter documented as array<mixed> — superglobals and
* get_option() returns are not guaranteed to have string keys.
*
* @param array<string, mixed> $input The superglobal array ($_POST, $_GET, etc.).
* @param string $key The key to look for.
* @param string $fallback Default value if key not found or not a string.
* @param array<mixed> $input The superglobal array ($_POST, $_GET, etc.).
* @param string $key The key to look for.
* @param string $fallback Default value if key not found or not a string.
* @return string
*/
function robotstxt_docmd_input_string( array $input, string $key, string $fallback = '' ): string {
@ -249,10 +251,12 @@ function robotstxt_docmd_input_string( array $input, string $key, string $fallba
* Provides PHPStan level 9 compliant type-narrowing for superglobal access.
*
* @since 1.0.1
* @since 1.2.3 Parameter documented as array<mixed> — superglobals and
* get_option() returns are not guaranteed to have string keys.
*
* @param array<string, mixed> $input The superglobal array ($_POST, $_GET, etc.).
* @param string $key The key to look for.
* @param int $fallback Default value if key not found or not numeric.
* @param array<mixed> $input The superglobal array ($_POST, $_GET, etc.).
* @param string $key The key to look for.
* @param int $fallback Default value if key not found or not numeric.
* @return int
*/
function robotstxt_docmd_input_int( array $input, string $key, int $fallback = 0 ): int {

View file

@ -27,9 +27,10 @@ function robotstxt_docmd_get_all_mappings(): array {
);
$query = new WP_Query( $args );
$posts = is_array( $query->posts ) ? $query->posts : array();
$mappings = array();
foreach ( $query->posts as $post ) {
foreach ( $posts as $post ) {
if ( ! ( $post instanceof WP_Post ) ) {
continue;
}

View file

@ -3,7 +3,7 @@
* Plugin Name: Documentation Markdown (by ROBOTSTXT)
* Plugin URI: https://www.robotstxt.software/plugins/robotstxt-documentation-markdown/
* Description: Synchronizes Markdown documentation from GitHub repositories to WordPress pages and posts automatically.
* Version: 1.2.2
* Version: 1.2.3
* Requires at least: 4.2
* Requires PHP: 8.0
* Security: robotstxt@robotstxt.es
@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
// Define plugin constants.
define( 'ROBOTSTXT_DOCMD_VERSION', '1.2.2' );
define( 'ROBOTSTXT_DOCMD_VERSION', '1.2.3' );
define( 'ROBOTSTXT_DOCMD_PLUGIN_FILE', __FILE__ );
define( 'ROBOTSTXT_DOCMD_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ROBOTSTXT_DOCMD_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
@ -146,6 +146,13 @@ function robotstxt_docmd_register_post_types() {
* @return void
*/
function robotstxt_docmd_register_admin_menu() {
// Base64 SVG data URI (document icon). Supported by core admin menus from
// WP 4.2 through 7.2+ (rendered as a 20px background image); aligns the icon
// with core's move from the Dashicons font to SVG (see WP ticket #65089),
// without requiring the WP 7.2-only wp_get_icon() API.
// phpcs:ignore Generic.Files.LineLength.TooLong -- 264-char base64 icon string cannot be wrapped.
$icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCI+PHBhdGggZmlsbD0iI2MzYzRjNyIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNSAxaDdsNCA0djE0SDVWMXptNyAxLjdWNmgzLjNMMTIgMi43ek03IDloNnYxSDdWOXptMCAzaDcuNXYxSDd2LTF6bTAgM2g3LjV2MUg3di0xeiIvPjwvc3ZnPg==';
// Main menu.
add_menu_page(
__( 'Documentation', 'robotstxt-documentation-markdown' ),
@ -153,7 +160,7 @@ function robotstxt_docmd_register_admin_menu() {
'edit_pages',
'robotstxt-docmd-mappings',
'robotstxt_docmd_render_mappings_page',
'dashicons-media-document',
$icon,
30
);
@ -735,11 +742,12 @@ function robotstxt_docmd_render_add_mapping_page() {
<?php
$post_types = get_post_types( array( 'public' => true ), 'objects' );
foreach ( $post_types as $post_type ) {
$label = $post_type->labels->singular_name;
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $post_type->name ),
selected( $data['target_post_type'], $post_type->name, false ),
esc_html( $post_type->labels->singular_name )
esc_html( is_string( $label ) ? $label : $post_type->name )
);
}
?>
@ -1579,6 +1587,11 @@ function robotstxt_docmd_debug_clear_cache() {
global $wpdb;
// Type-narrow the global (PHPStan level 10: global $wpdb is mixed).
if ( ! $wpdb instanceof wpdb ) {
return;
}
$result = array(
'type' => 'error',
'message' => '',
@ -1586,16 +1599,19 @@ function robotstxt_docmd_debug_clear_cache() {
);
// Delete all plugin transients.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct query acceptable for cache clearing operation.
// Escaping uses the esc_sql() + esc_like() chain documented in wpdb::esc_like():
// wpdb::prepare() cannot be used here because table-name interpolation makes
// the query string non-literal (wordpress-stubs types $query as literal-string).
$transient_like = esc_sql( $wpdb->esc_like( '_transient_robotstxt_docmd_' ) ) . '%';
$timeout_like = esc_sql( $wpdb->esc_like( '_transient_timeout_robotstxt_docmd_' ) ) . '%';
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Bulk cache-clearing delete; values escaped above via esc_sql() + esc_like().
$deleted = $wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options}
WHERE option_name LIKE %s
OR option_name LIKE %s",
$wpdb->esc_like( '_transient_robotstxt_docmd_' ) . '%',
$wpdb->esc_like( '_transient_timeout_robotstxt_docmd_' ) . '%'
)
"DELETE FROM {$wpdb->options}
WHERE option_name LIKE '{$transient_like}'
OR option_name LIKE '{$timeout_like}'"
);
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
if ( false !== $deleted ) {
$result['type'] = 'success';

View file

@ -90,27 +90,29 @@ function robotstxt_docmd_uninstall(): void {
function robotstxt_docmd_delete_transients_by_prefix( string $prefix ): void {
global $wpdb;
// Sanitize prefix for LIKE query.
$transient_prefix = $wpdb->esc_like( '_transient_' . $prefix ) . '%';
$transient_timeout_prefix = $wpdb->esc_like( '_transient_timeout_' . $prefix ) . '%';
// Type-narrow the global (PHPStan level 10: global $wpdb is mixed).
if ( ! $wpdb instanceof wpdb ) {
return;
}
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Required for bulk pattern-based deletion; no WordPress API available for this operation.
// Sanitize prefix for the LIKE pattern. Escaping uses the esc_sql() +
// esc_like() chain documented in wpdb::esc_like(): wpdb::prepare() cannot
// be used here because table-name interpolation makes the query string
// non-literal (wordpress-stubs types $query as literal-string).
$transient_prefix = esc_sql( $wpdb->esc_like( '_transient_' . $prefix ) ) . '%';
$transient_timeout_prefix = esc_sql( $wpdb->esc_like( '_transient_timeout_' . $prefix ) ) . '%';
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Required for bulk pattern-based deletion; no WordPress API available. Values escaped above via esc_sql() + esc_like().
// Delete transient values.
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
$transient_prefix
)
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$transient_prefix}'"
);
// Delete transient timeouts.
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
$transient_timeout_prefix
)
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$transient_timeout_prefix}'"
);
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
// Run uninstall.

2
vendor/autoload.php vendored
View file

@ -19,4 +19,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitc097ca862608a882f291ae6b935e271c::getLoader();
return ComposerAutoloaderInit58fc5ab3eee1b67eedbe2aa42d9005e6::getLoader();

View file

@ -366,7 +366,6 @@ return array(
'Nette\\Utils\\AssertionException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\Callback' => $vendorDir . '/nette/utils/src/Utils/Callback.php',
'Nette\\Utils\\DateTime' => $vendorDir . '/nette/utils/src/Utils/DateTime.php',
'Nette\\Utils\\DateTimeImmutable' => $vendorDir . '/nette/utils/src/Utils/DateTimeImmutable.php',
'Nette\\Utils\\FileInfo' => $vendorDir . '/nette/utils/src/Utils/FileInfo.php',
'Nette\\Utils\\FileSystem' => $vendorDir . '/nette/utils/src/Utils/FileSystem.php',
'Nette\\Utils\\Finder' => $vendorDir . '/nette/utils/src/Utils/Finder.php',
@ -383,9 +382,6 @@ return array(
'Nette\\Utils\\JsonException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\ObjectHelpers' => $vendorDir . '/nette/utils/src/Utils/ObjectHelpers.php',
'Nette\\Utils\\Paginator' => $vendorDir . '/nette/utils/src/Utils/Paginator.php',
'Nette\\Utils\\Process' => $vendorDir . '/nette/utils/src/Utils/Process.php',
'Nette\\Utils\\ProcessFailedException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\ProcessTimeoutException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\Random' => $vendorDir . '/nette/utils/src/Utils/Random.php',
'Nette\\Utils\\Reflection' => $vendorDir . '/nette/utils/src/Utils/Reflection.php',
'Nette\\Utils\\ReflectionMethod' => $vendorDir . '/nette/utils/src/Utils/ReflectionMethod.php',

View file

@ -8,7 +8,7 @@ $baseDir = dirname($vendorDir);
return array(
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'),
'Nette\\' => array($vendorDir . '/nette/schema/src', $vendorDir . '/nette/utils/src'),
'Nette\\' => array($vendorDir . '/nette/utils/src'),
'League\\Config\\' => array($vendorDir . '/league/config/src'),
'League\\CommonMark\\' => array($vendorDir . '/league/commonmark/src'),
'Dflydev\\DotAccessData\\' => array($vendorDir . '/dflydev/dot-access-data/src'),

View file

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitc097ca862608a882f291ae6b935e271c
class ComposerAutoloaderInit58fc5ab3eee1b67eedbe2aa42d9005e6
{
private static $loader;
@ -24,16 +24,16 @@ class ComposerAutoloaderInitc097ca862608a882f291ae6b935e271c
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitc097ca862608a882f291ae6b935e271c', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit58fc5ab3eee1b67eedbe2aa42d9005e6', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitc097ca862608a882f291ae6b935e271c', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit58fc5ab3eee1b67eedbe2aa42d9005e6', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitc097ca862608a882f291ae6b935e271c::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit58fc5ab3eee1b67eedbe2aa42d9005e6::getInitializer($loader));
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitc097ca862608a882f291ae6b935e271c::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit58fc5ab3eee1b67eedbe2aa42d9005e6::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View file

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitc097ca862608a882f291ae6b935e271c
class ComposerStaticInit58fc5ab3eee1b67eedbe2aa42d9005e6
{
public static $files = array (
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
@ -46,8 +46,7 @@ class ComposerStaticInitc097ca862608a882f291ae6b935e271c
),
'Nette\\' =>
array (
0 => __DIR__ . '/..' . '/nette/schema/src',
1 => __DIR__ . '/..' . '/nette/utils/src',
0 => __DIR__ . '/..' . '/nette/utils/src',
),
'League\\Config\\' =>
array (
@ -424,7 +423,6 @@ class ComposerStaticInitc097ca862608a882f291ae6b935e271c
'Nette\\Utils\\AssertionException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\Callback' => __DIR__ . '/..' . '/nette/utils/src/Utils/Callback.php',
'Nette\\Utils\\DateTime' => __DIR__ . '/..' . '/nette/utils/src/Utils/DateTime.php',
'Nette\\Utils\\DateTimeImmutable' => __DIR__ . '/..' . '/nette/utils/src/Utils/DateTimeImmutable.php',
'Nette\\Utils\\FileInfo' => __DIR__ . '/..' . '/nette/utils/src/Utils/FileInfo.php',
'Nette\\Utils\\FileSystem' => __DIR__ . '/..' . '/nette/utils/src/Utils/FileSystem.php',
'Nette\\Utils\\Finder' => __DIR__ . '/..' . '/nette/utils/src/Utils/Finder.php',
@ -441,9 +439,6 @@ class ComposerStaticInitc097ca862608a882f291ae6b935e271c
'Nette\\Utils\\JsonException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\ObjectHelpers' => __DIR__ . '/..' . '/nette/utils/src/Utils/ObjectHelpers.php',
'Nette\\Utils\\Paginator' => __DIR__ . '/..' . '/nette/utils/src/Utils/Paginator.php',
'Nette\\Utils\\Process' => __DIR__ . '/..' . '/nette/utils/src/Utils/Process.php',
'Nette\\Utils\\ProcessFailedException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\ProcessTimeoutException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php',
'Nette\\Utils\\Random' => __DIR__ . '/..' . '/nette/utils/src/Utils/Random.php',
'Nette\\Utils\\Reflection' => __DIR__ . '/..' . '/nette/utils/src/Utils/Reflection.php',
'Nette\\Utils\\ReflectionMethod' => __DIR__ . '/..' . '/nette/utils/src/Utils/ReflectionMethod.php',
@ -466,9 +461,9 @@ class ComposerStaticInitc097ca862608a882f291ae6b935e271c
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitc097ca862608a882f291ae6b935e271c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc097ca862608a882f291ae6b935e271c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc097ca862608a882f291ae6b935e271c::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit58fc5ab3eee1b67eedbe2aa42d9005e6::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit58fc5ab3eee1b67eedbe2aa42d9005e6::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit58fc5ab3eee1b67eedbe2aa42d9005e6::$classMap;
}, null, ClassLoader::class);
}

View file

@ -80,17 +80,17 @@
},
{
"name": "league/commonmark",
"version": "2.10.0",
"version_normalized": "2.10.0.0",
"version": "2.10.7",
"version_normalized": "2.10.7.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "d2d1aa8b35e072966c89bc0c66cf926e56767dc4"
"reference": "8eb53e906fd60c67038d22f1f1cab420ed58b8be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d2d1aa8b35e072966c89bc0c66cf926e56767dc4",
"reference": "d2d1aa8b35e072966c89bc0c66cf926e56767dc4",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/8eb53e906fd60c67038d22f1f1cab420ed58b8be",
"reference": "8eb53e906fd60c67038d22f1f1cab420ed58b8be",
"shasum": ""
},
"require": {
@ -124,7 +124,7 @@
"suggest": {
"symfony/yaml": "v2.3+ required if using the Front Matter extension"
},
"time": "2026-08-11T16:06:25+00:00",
"time": "2026-10-31T13:35:37+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -275,42 +275,37 @@
},
{
"name": "nette/schema",
"version": "v1.3.6",
"version_normalized": "1.3.6.0",
"version": "v1.2.5",
"version_normalized": "1.2.5.0",
"source": {
"type": "git",
"url": "https://github.com/nette/schema.git",
"reference": "c54350438cd6914616f790a49cb424605f421562"
"reference": "0462f0166e823aad657c9224d0f849ecac1ba10a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/schema/zipball/c54350438cd6914616f790a49cb424605f421562",
"reference": "c54350438cd6914616f790a49cb424605f421562",
"url": "https://api.github.com/repos/nette/schema/zipball/0462f0166e823aad657c9224d0f849ecac1ba10a",
"reference": "0462f0166e823aad657c9224d0f849ecac1ba10a",
"shasum": ""
},
"require": {
"nette/utils": "^4.0",
"php": "8.1 - 8.5"
"nette/utils": "^2.5.7 || ^3.1.5 || ^4.0",
"php": "7.1 - 8.3"
},
"require-dev": {
"nette/phpstan-rules": "^1.0",
"nette/tester": "^2.6",
"phpstan/extension-installer": "^1.4@stable",
"phpstan/phpstan": "^2.1.39@stable",
"tracy/tracy": "^2.8"
"nette/tester": "^2.3 || ^2.4",
"phpstan/phpstan-nette": "^1.0",
"tracy/tracy": "^2.7"
},
"time": "2026-08-16T21:58:41+00:00",
"time": "2023-10-05T20:37:59+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
"dev-master": "1.2-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Nette\\": "src"
},
"classmap": [
"src/"
]
@ -339,27 +334,27 @@
],
"support": {
"issues": "https://github.com/nette/schema/issues",
"source": "https://github.com/nette/schema/tree/v1.3.6"
"source": "https://github.com/nette/schema/tree/v1.2.5"
},
"install-path": "../nette/schema"
},
{
"name": "nette/utils",
"version": "v4.1.5",
"version_normalized": "4.1.5.0",
"version": "v4.0.11",
"version_normalized": "4.0.11.0",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "b043439dbdf954e6c28b5ea7e34b0100f83165e0"
"reference": "c9958d457077885860569245ffbf66f8131f36cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/b043439dbdf954e6c28b5ea7e34b0100f83165e0",
"reference": "b043439dbdf954e6c28b5ea7e34b0100f83165e0",
"url": "https://api.github.com/repos/nette/utils/zipball/c9958d457077885860569245ffbf66f8131f36cb",
"reference": "c9958d457077885860569245ffbf66f8131f36cb",
"shasum": ""
},
"require": {
"php": "8.2 - 8.5"
"php": "8.0 - 8.6"
},
"conflict": {
"nette/finder": "<3",
@ -367,25 +362,23 @@
},
"require-dev": {
"jetbrains/phpstorm-attributes": "^1.2",
"nette/phpstan-rules": "^1.0",
"nette/tester": "^2.5",
"phpstan/extension-installer": "^1.4@stable",
"phpstan/phpstan": "^2.1@stable",
"phpstan/phpstan-nette": "^2.0@stable",
"tracy/tracy": "^2.9"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::chr(), ord() and reverse()",
"ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()",
"ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()"
},
"time": "2026-07-17T23:02:45+00:00",
"time": "2026-10-21T16:50:30+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-master": "4.0-dev"
}
},
"installation-source": "dist",
@ -433,7 +426,7 @@
],
"support": {
"issues": "https://github.com/nette/utils/issues",
"source": "https://github.com/nette/utils/tree/v4.1.5"
"source": "https://github.com/nette/utils/tree/v4.0.11"
},
"install-path": "../nette/utils"
},
@ -492,23 +485,23 @@
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.7.1",
"version_normalized": "3.7.1.0",
"version": "v3.0.2",
"version_normalized": "3.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d"
"reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/f3202fa1b5097b0af062dc978b32ecf63404e31d",
"reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c",
"reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c",
"shasum": ""
},
"require": {
"php": ">=8.1"
"php": ">=8.0.2"
},
"time": "2026-06-05T06:23:12+00:00",
"time": "2022-01-02T09:55:41+00:00",
"type": "library",
"extra": {
"thanks": {
@ -516,7 +509,7 @@
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.7-dev"
"dev-main": "3.0-dev"
}
},
"installation-source": "dist",
@ -542,7 +535,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.7.1"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2"
},
"funding": [
{
@ -553,10 +546,6 @@
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
@ -566,23 +555,23 @@
},
{
"name": "symfony/polyfill-php80",
"version": "v1.37.0",
"version_normalized": "1.37.0.0",
"version": "v1.43.0",
"version_normalized": "1.43.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411"
"reference": "9c6a5d6b01ca51d486c813e9a9c0ed55f208bb74"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dfb55726c3a76ea3b6459fcfda1ec2d80a682411",
"reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/9c6a5d6b01ca51d486c813e9a9c0ed55f208bb74",
"reference": "9c6a5d6b01ca51d486c813e9a9c0ed55f208bb74",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"time": "2026-04-10T16:19:22+00:00",
"time": "2026-09-25T15:50:05+00:00",
"type": "library",
"extra": {
"thanks": {
@ -629,7 +618,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.37.0"
"source": "https://github.com/symfony/polyfill-php80/tree/v1.43.0"
},
"funding": [
{

View file

@ -20,9 +20,9 @@
'dev_requirement' => false,
),
'league/commonmark' => array(
'pretty_version' => '2.10.0',
'version' => '2.10.0.0',
'reference' => 'd2d1aa8b35e072966c89bc0c66cf926e56767dc4',
'pretty_version' => '2.10.7',
'version' => '2.10.7.0',
'reference' => '8eb53e906fd60c67038d22f1f1cab420ed58b8be',
'type' => 'library',
'install_path' => __DIR__ . '/../league/commonmark',
'aliases' => array(),
@ -38,18 +38,18 @@
'dev_requirement' => false,
),
'nette/schema' => array(
'pretty_version' => 'v1.3.6',
'version' => '1.3.6.0',
'reference' => 'c54350438cd6914616f790a49cb424605f421562',
'pretty_version' => 'v1.2.5',
'version' => '1.2.5.0',
'reference' => '0462f0166e823aad657c9224d0f849ecac1ba10a',
'type' => 'library',
'install_path' => __DIR__ . '/../nette/schema',
'aliases' => array(),
'dev_requirement' => false,
),
'nette/utils' => array(
'pretty_version' => 'v4.1.5',
'version' => '4.1.5.0',
'reference' => 'b043439dbdf954e6c28b5ea7e34b0100f83165e0',
'pretty_version' => 'v4.0.11',
'version' => '4.0.11.0',
'reference' => 'c9958d457077885860569245ffbf66f8131f36cb',
'type' => 'library',
'install_path' => __DIR__ . '/../nette/utils',
'aliases' => array(),
@ -74,18 +74,18 @@
'dev_requirement' => false,
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'v3.7.1',
'version' => '3.7.1.0',
'reference' => 'f3202fa1b5097b0af062dc978b32ecf63404e31d',
'pretty_version' => 'v3.0.2',
'version' => '3.0.2.0',
'reference' => '26954b3d62a6c5fd0ea8a2a00c0353a14978d05c',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/polyfill-php80' => array(
'pretty_version' => 'v1.37.0',
'version' => '1.37.0.0',
'reference' => 'dfb55726c3a76ea3b6459fcfda1ec2d80a682411',
'pretty_version' => 'v1.43.0',
'version' => '1.43.0.0',
'reference' => '9c6a5d6b01ca51d486c813e9a9c0ed55f208bb74',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-php80',
'aliases' => array(),

View file

@ -4,8 +4,8 @@
$issues = array();
if (!(PHP_VERSION_ID >= 80200)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.2.0". You are running ' . PHP_VERSION . '.';
if (!(PHP_VERSION_ID >= 80002)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.2". You are running ' . PHP_VERSION . '.';
}
if ($issues) {

View file

@ -6,6 +6,56 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
## [Unreleased][unreleased]
## [2.10.7] - 2026-10-31
### Fixed
- Fixed `AutolinkExtension` keeping trailing punctuation inside very long URLs containing long runs of punctuation, and removed the excessive regex backtracking that caused it (#1170)
## [2.10.6] - 2026-10-30
### Fixed
- Fixed `ExternalLinkExtension` not treating some links as external when browsers would navigate to an external host, such as `https:///example.com`, `http:example.com`, or `///example.com`; hosts are now determined the way browsers do (#1169)
## [2.10.5] - 2026-10-30
### Fixed
- Fixed link reference definitions keeping a partially parsed title when the title on the following line is never closed or is followed by other text; the definition now has no title, as the spec requires (#1162)
- Fixed task list items being recognized when the `[ ]` or `[x]` marker is directly followed by other content (`- [x]done`); the GFM spec requires whitespace after the marker (#1164)
- Fixed the content indentation of a list item whose content is a single character after two to four spaces (`- a`): it was computed as if one space followed the marker, so the next line could be read as part of the item, nesting a following item inside it (#1163)
- Fixed a table inside a block quote or list item absorbing the lines that follow it as table rows when those lines are lazy continuation lines (not prefixed with `>` or indented); they now end the container as in GitHub's `cmark-gfm` (#1165)
- Fixed link reference definitions accepting an unescaped `(` inside a parenthesized title (#1168)
## [2.10.4] - 2026-10-17
### Fixed
- Fixed `HeadingPermalinkExtension` overwriting an `id` set on a heading by the `AttributesExtension` when `heading_permalink/apply_id_to_heading` is enabled; the existing `id` is now used (with the configured prefix) for both the heading and its permalink (#1159, #1160)
- Fixed Symfony `DebugClassLoader` deprecation notice about `ArrayCollection::offsetGet()` by adding an explicit `@return` annotation (#1158)
## [2.10.3] - 2026-09-21
### Fixed
- Fixed footnote links and backlinks pointing at the wrong anchor when `footnote/footnote_id_prefix` or `footnote/ref_id_prefix` contains an uppercase character; the configured prefix is now emitted verbatim in the `href` as it already was in the matching `id` (#524)
- Fixed inline raw HTML tags being escaped when the tag name or an attribute name contains an uppercase letter, such as `<svg viewBox="...">` or `<Warning>` (#1096)
## [2.10.2] - 2026-09-21
This is a **security release** to address a denial of service vulnerability in the `Table` extension and a raw HTML filtering bypass in the `DisallowedRawHtml` extension.
### Changed
- Improved performance of parsing table delimiter rows and splitting table rows into cells by scanning bytes directly instead of stepping a `Cursor` (roughly 4x faster for delimiter rows and 6x for cell splitting, and more on multibyte rows)
### Fixed
- Fixed `DisallowedRawHtmlRenderer` not blocking raw HTML that ends with a disallowed tag name, such as a line containing only `<script` (GHSA-97jj-33gv-5xf9)
- Fixed quadratic-time parsing of long paragraphs when the `Table` extension is enabled (GHSA-3q6v-r5mr-hxv8)
- Fixed table detection to match the GFM spec and reference implementation:
- Header rows no longer require a `|` character
- Header rows must now have the same number of cells as the delimiter row (previously, fewer cells were accepted)
## [2.10.1] - 2026-09-07
### Fixed
- Accept `unordered_list_markers` config in InlinesOnlyExtension (#1015, #1151)
## [2.10.0] - 2026-08-11
This is a **security release** to address a denial of service vulnerability in the `AttributesExtension`.
@ -834,7 +884,14 @@ No changes were introduced since the previous release.
- Alternative 1: Use `CommonMarkConverter` or `GithubFlavoredMarkdownConverter` if you don't need to customize the environment
- Alternative 2: Instantiate a new `Environment` and add the necessary extensions yourself
[unreleased]: https://github.com/thephpleague/commonmark/compare/2.10.0...HEAD
[unreleased]: https://github.com/thephpleague/commonmark/compare/2.10.7...HEAD
[2.10.7]: https://github.com/thephpleague/commonmark/compare/2.10.6...2.10.7
[2.10.6]: https://github.com/thephpleague/commonmark/compare/2.10.5...2.10.6
[2.10.5]: https://github.com/thephpleague/commonmark/compare/2.10.4...2.10.5
[2.10.4]: https://github.com/thephpleague/commonmark/compare/2.10.3...2.10.4
[2.10.3]: https://github.com/thephpleague/commonmark/compare/2.10.2...2.10.3
[2.10.2]: https://github.com/thephpleague/commonmark/compare/2.10.1...2.10.2
[2.10.1]: https://github.com/thephpleague/commonmark/compare/2.10.0...2.10.1
[2.10.0]: https://github.com/thephpleague/commonmark/compare/2.9.2...2.10.0
[2.9.2]: https://github.com/thephpleague/commonmark/compare/2.9.1...2.9.2
[2.9.1]: https://github.com/thephpleague/commonmark/compare/2.9.0...2.9.1

View file

@ -133,7 +133,7 @@ When a new **major** version is released (e.g. `1.6` -> `2.0`), the previous one
## 👷‍♀️ Contributing
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure with us.
To report a security vulnerability, please see our [security policy](.github/SECURITY.md).
If you encounter a bug in the spec, please report it to the [CommonMark] project. Any resulting fix will eventually be implemented in this project as well.

View file

@ -107,13 +107,8 @@ final class UrlAutolinkParser implements InlineParserInterface
return false;
}
$url = $matches[0];
// Does the URL end with punctuation that should be stripped?
if (\preg_match('/(.+?)([?!.,:*_~]+)$/', $url, $matches)) {
// Add the punctuation later
$url = $matches[1];
}
// Strip trailing punctuation; it's left on the cursor to be parsed as text
$url = \rtrim($matches[0], '?!.,:*_~');
// Does the URL end with something that looks like an entity reference?
if (\preg_match('/(.+)(&[A-Za-z0-9]+;)$/', $url, $matches)) {

View file

@ -123,7 +123,7 @@ final class ListBlockStartParser implements BlockStartParserInterface, Configura
}
}
$blankItem = $cursor->peek() === null;
$blankItem = $cursor->isAtEnd();
$spacesAfterMarker = $cursor->getColumn() - $spacesStartCol;
if ($spacesAfterMarker >= 5 || $spacesAfterMarker < 1 || $blankItem) {

View file

@ -45,9 +45,11 @@ final class DisallowedRawHtmlRenderer implements NodeRendererInterface, Configur
return $rendered;
}
$regex = \sprintf('/<(\/?(?:%s)[\s\/>])/i', \implode('|', \array_map('preg_quote', $tags)));
// The tag name may also end the rendered HTML: the block parser accepts a bare
// `<script` line, and browsers treat the following block as its attributes.
$regex = \sprintf('/<(\/?(?:%s)(?:[\s\/>]|$))/i', \implode('|', \array_map('preg_quote', $tags)));
// Match these types of tags: <title> </title> <title x="sdf"> <title/> <title />
// Match these types of tags: <title> </title> <title x="sdf"> <title/> <title /> <title
return \preg_replace($regex, '&lt;$1', $rendered);
}

View file

@ -43,9 +43,9 @@ final class ExternalLinkProcessor
continue;
}
$host = \parse_url($link->getUrl(), PHP_URL_HOST);
if (! \is_string($host)) {
// Something is terribly wrong with this URL
$host = self::getHost($link->getUrl());
if ($host === null) {
// Relative links and non-network schemes like mailto: have no host to compare
continue;
}
@ -97,6 +97,28 @@ final class ExternalLinkProcessor
}
}
/**
* Determines which host a browser would navigate to, which parse_url() doesn't always agree with
* on its own (for example, it finds no host in "https:///example.com" or "///example.com")
*/
private static function getHost(string $url): ?string
{
// Browsers ignore these characters, so links not created by the parser could use them to obscure the host
$url = \str_replace(["\t", "\n", "\r"], '', \trim($url, "\x00..\x20"));
// For these "special" schemes (and scheme-relative URLs), browsers accept any number of slashes before the
// host, even none, and treat "\" like "/". parse_url() needs exactly "//", so we rewrite the URL to match.
// Without slashes ("https:example.com") a browser may instead resolve the URL relative to the current page,
// but we can't know the page's scheme, so we assume the worst and treat it as a host.
if (\preg_match('~^(?:(?:https?|ftp|wss?):|(?=[/\\\\]{2}))~i', $url, $matches) === 1) {
$url = '//' . \ltrim(\strtr(\substr($url, \strlen($matches[0])), '\\', '/'), '/');
}
$host = \parse_url($url, PHP_URL_HOST);
return \is_string($host) && $host !== '' ? $host : null;
}
/**
* @internal This method is only public so we can easily test it. DO NOT USE THIS OUTSIDE OF THIS EXTENSION!
*

Some files were not shown because too many files have changed in this diff Show more