Fix AutolinkExtension incorrectly matching URLs after invalid www. prefix#1103
Merged
colinodell merged 2 commits intomainfrom Nov 26, 2025
Merged
Fix AutolinkExtension incorrectly matching URLs after invalid www. prefix#1103colinodell merged 2 commits intomainfrom
colinodell merged 2 commits intomainfrom
Conversation
Co-authored-by: colinodell <202034+colinodell@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix AutolinkExtension link identification issue
Fix AutolinkExtension incorrectly matching URLs after invalid www. prefix
Nov 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When text contains
www.(with space) followed by a valid URL, the parser incorrectly skips the invalid prefix and matches the later URL, causing text deletion and malformed output.Changes
Root cause: Unanchored regex in
UrlAutolinkParser::REGEXmatches URLs anywhere in the cursor's remainder, not just at the current position.Fix: Anchor regex to start of string with
^:Tests: Added regression cases for:
www.followed by valid URL (original issue)www. example.com(space between prefix and domain)www. https://example.com(double space scenario)All existing URL patterns (www., http://, https://, ftp://) continue to match correctly.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/DaveRandom/LibDNS/zipball/b84c94e8fe6b7ee4aecfe121bfe3b6177d303c8a/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/RyFLIU /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/Nyholm/psr7/zipball/a71f2b11690f4b24d099d6b16690a90ae14fc6f3/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/amphp/amp/zipball/fa0ab33a6f47a82929c38d03ca47ebb71086a93f/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/amphp/dns/zipball/78eb3db5fc69bf2fc0cb503c4fcba667bc223c71/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/amphp/parallel/zipball/321b45ae771d9c33a068186b24117e3cd1c48dce/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/amphp/pipeline/zipball/7b52598c2e9105ebcddf247fc523161581930367/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/amphp/serialization/zipball/693e77b2fb0b266c3c7d622317f881de44ae94a1/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/amphp/socket/zipball/58e0422221825b79681b72c50c47a930be7bf1e1/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/amphp/sync/zipball/217097b785130d77cfcc58ff583cf26cd1770bf1/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/RyFLIU /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/cebe/markdown/zipball/9bac5e971dd391e2802dca5400bbeacbaea9eb86/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/ca-bundle/zipball/1905981ee626e6f852448b7aaa978f8666c5bc54/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/package-versions-deprecated/zipball/b4f54f74ef3453349c24a845d22392cd31e65f1d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/RyFLIU /usr/bin/composer install(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/cweiske/jsonmapper/zipball/8e76efb98ee8b6afc54687045e1b8dba55ac76e5/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/a23a2bf4f31d3518f3ecb38660c95715dfead60f/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/doctrine/lexer/zipball/31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/erusev/parsedown/zipball/fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/a9e113dbc7d849e35b8776da39edaf4313b7b6c9/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/jonnyeom/php-coding-standard/zipball/49eee067015382521807d0b5d053eb6a3f65855e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/kelunik/certificate/zipball/7e00d498c264d5eb4f78c69f41c8bd6719c0199e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/lanthaler/IRI/zipball/cbd44fa913e00ea624241b38cefaa99da8d71341/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/lanthaler/JsonLD/zipball/537e68e87a6bce23e57c575cd5dcac1f67ce25d8/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/michelf/php-markdown/zipball/eb176f173fbac58a045aff78e55f833264b34e71/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/nette/schema/zipball/2befc2f42d7c715fd9d95efc31b1081e5d765004/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/nette/utils/zipball/505a30ad386daa5211f08a318e47015b501cad30/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/oscarotero/html-parser/zipball/10f3219267a365d9433f2f7d1694209c9d436c8d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-embed/Embed/zipball/b2ea091a5586c14ea5f2c5bf52fb0ef38e5aef87/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/90a04bcbf03784066f16038e87e23a0a83cee3c2/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/92a98ada2b93d9b201a613cb5a33584dde25f195/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/revoltphp/event-loop/zipball/09bf1bf7f7f574453efe43044b06fafe12216eb3/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/schmittjoh/metadata/zipball/7ca240dcac0c655eb15933ee55736ccd2ea0d7a6/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/schmittjoh/php-option/zipball/638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/schmittjoh/serializer/zipball/7c88b1b02ff868eecc870eeddbb3b1250e4bd89c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/scrutinizer-ci/ocular/zipball/dda3540f7458b2645cee2a02b24291914769c41c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/spatie/array-to-xml/zipball/6a740f39415aee8886aea10333403adc77d50791/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/filesystem/zipball/581d9d4dbd0159d3e960b4786edd0640820d0d09/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/finder/zipball/340b9ed7320570f319028a2cbec46d40535e94bd/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/yaml/zipball/6c84a4b55aee4cd02034d1c528e83f69ddf63810/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/thephpleague/uri-interfaces/zipball/ccbfb51c0445298e7e0b7f4481b942f589665368/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/thephpleague/uri/zipball/f625804987a0a9112d954f9209d91fec52182344/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/vimeo/psalm/zipball/38fc8444edf0cebc9205296ee6e30e906ade783b/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/tvLUUF /usr/bin/composer install --no-interaction(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.