Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pfefferle
Copy link
Owner

The current code seems to parse the nickname, but there is no fallback implemented. This PR tries to fall back to nickname and given-name + family-name if name is empty.

This fixes fed.brid.gy webmentions.

Screenshot 2025-07-09 at 09 33 02

@pfefferle pfefferle self-assigned this Jul 9, 2025
@pfefferle pfefferle requested a review from Copilot July 9, 2025 07:33
Copy link

@Copilot Copilot AI left a 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 name in class-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 name property is missing but nickname and/or given-name and family-name are 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 but p-nickname and/or p-given-name and p-family-name elements are present, to cover fallback parsing in HTML cases.
    <span class="p-nickname">elena</span>

@pfefferle
Copy link
Owner Author

@snarfed fed.brid.gy is really breaking the complete classic webmention mf2 parsing!!

@pfefferle
Copy link
Owner Author

@snarfed can you tell me the target for https://brid.gy/comment/mastodon/@[email protected]/114818746807544274/114818746807544274? is it https://notiz.blog/author/matthias-pfefferle/?

@snarfed
Copy link
Contributor

snarfed commented Jul 9, 2025

Hey @pfefferle, sorry for the trouble! Looks like the target there probably should have been https://notiz.blog/author/matthias-pfefferle/, but we actually sent the webmention with target https://notiz.blog/. Evidently we got confused. Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants