Match hyphens in @mentions#642
Merged
Merged
Conversation
The mention matcher used /@(\w+)/, where \w excludes hyphens, so a mention of a user whose slug contains a hyphen (e.g. @dominic-huxley) only captured the part before the hyphen. The truncated slug matched no user, so the mention rendered as plain text instead of a link. Allow hyphens in the captured username with /@([\w-]+)/. WordPress nicenames are limited to lowercase letters, digits, and hyphens, so this covers all valid slugs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
This time targeted at main. |
kadamwhite
approved these changes
Jun 1, 2026
Member
|
Just noting related bug is humanmade/wp-simple-saml#119 which allowed creating these usernames in the first place (but they're allowed on single site anyway, so still a H2 bug anyway) |
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.
Problem
@mentions of users whose slug contains a hyphen (e.g.
@dominic-huxley) render as plain text instead of a link, while single-token names (e.g.@tomnowell) link correctly. This is a parsing bug, not a missing-account issue — the affected users have valid author archives.Cause
src/matchers.jsmatched mentions with/@(\w+)/.\wis[A-Za-z0-9_]and excludes-, so@dominic-huxleyonly captureddominic.Mention.jsthen looked up the slugdominic, found no user, andAuthorLinkreturns its children verbatim (no link) when there is no user.Fix
Allow hyphens in the captured username:
/@([\w-]+)/. WordPress user nicenames are limited to lowercase letters, digits, and hyphens, so this covers every valid slug. Verified locally: hyphenated mentions now link.Targets
mainso the release Action rebuilds the bundle on merge.🤖 Generated with Claude Code