-
-
Notifications
You must be signed in to change notification settings - Fork 30
Fix: Implement nickname fallback for mf2 parser #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces fallback logic for the author’s name property: if name is empty it uses nickname, or concatenates given-name + family-name. It also adds new JSON and HTML fixtures to the test suite.
- Implement fallback for missing
nameinclass-mf2.php - Add a basic JSON fixture with
author.name - Add an HTML fixture containing
p-nickname
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/data/mf2/brid-gy-mastodon.json | Add minimal JSON fixture for author with name |
| tests/data/mf2/brid-gy-mastodon.html | Add HTML fixture containing author metadata including nickname |
| includes/Handler/class-mf2.php | Implement nickname and given-name/family-name fallback for missing name |
Comments suppressed due to low confidence (3)
includes/Handler/class-mf2.php:117
- Consider updating the method's docblock to document the new fallback behavior for the author name, improving maintainability and clarity for future contributors.
if ( empty( $author['name'] ) ) {
tests/data/mf2/brid-gy-mastodon.json:1
- It would be beneficial to add a test fixture where the
nameproperty is missing butnicknameand/orgiven-nameandfamily-nameare provided, verifying the fallback logic works as expected.
{
tests/data/mf2/brid-gy-mastodon.html:36
- Consider adding an HTML fixture where the
<span class="p-name">element is absent butp-nicknameand/orp-given-nameandp-family-nameelements are present, to cover fallback parsing in HTML cases.
<span class="p-nickname">elena</span>
|
@snarfed fed.brid.gy is really breaking the complete classic webmention mf2 parsing!! |
|
@snarfed can you tell me the |
and improve regex to support `<a>` with nested HTML
|
Hey @pfefferle, sorry for the trouble! Looks like the target there probably should have been |
|
@snarfed any idea or advice how I can best solve or at least work around this? I get a lot of "broken" Webmentions! |
|
Damn, sorry. We made some progress on this recently in snarfed/bridgy#1926 , but still obviously not all the way fixed. Will look more. |
|
No Problem and thanks 🙂 |
The current code seems to parse the
nickname, but there is no fallback implemented. This PR tries to fall back tonicknameandgiven-name+family-nameifnameis empty.This fixes fed.brid.gy webmentions.