Skip to content

fix: support name attribute when extracting HTML meta tags#5822

Open
mango766 wants to merge 1 commit intousememos:mainfrom
mango766:fix/html-meta-name-attr
Open

fix: support name attribute when extracting HTML meta tags#5822
mango766 wants to merge 1 commit intousememos:mainfrom
mango766:fix/html-meta-name-attr

Conversation

@mango766
Copy link
Copy Markdown

@mango766 mango766 commented Apr 9, 2026

Fixes #5821

Problem

The extractMetaProperty function in plugin/httpgetter/html_meta.go only matched meta tags with the property attribute (used by Open Graph), but standard HTML meta descriptions use the name attribute:

<!-- Standard HTML (was broken) -->
<meta name="description" content="Page description">

<!-- Open Graph (worked fine) -->
<meta property="og:description" content="Page description">

As a result, link previews would silently drop the description for any page that doesn't use Open Graph markup.

Fix

Add attr.Key == "name" as an alternative to attr.Key == "property" in the attribute check:

if (attr.Key == "property" || attr.Key == "name") && attr.Val == prop {

This is a one-line change that makes the extractor match both standard HTML and Open Graph meta tags.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced metadata extraction from web pages to recognize additional tag formats, improving detection of page descriptions, titles, and images.

The extractMetaProperty function only checked for the property attribute
in HTML meta tags, which is used for Open Graph (og:title, og:image etc).
Standard HTML meta tags like <meta name="description" content="..."> use
the name attribute instead, so descriptions were never extracted from
pages that don't use Open Graph markup.
@mango766 mango766 requested a review from a team as a code owner April 9, 2026 06:24
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba970514-dbeb-4afe-bf64-0b3a17703ccc

📥 Commits

Reviewing files that changed from the base of the PR and between 938c405 and 0d66209.

📒 Files selected for processing (1)
  • plugin/httpgetter/html_meta.go

📝 Walkthrough

Walkthrough

The extractMetaProperty function in the HTML metadata extraction module now checks both property and name attributes on HTML meta tags when extracting page metadata. Previously, it only checked the property attribute, which caused standard meta descriptions to be missed.

Changes

Cohort / File(s) Summary
HTML Meta Extraction
plugin/httpgetter/html_meta.go
Modified extractMetaProperty to match metadata keys against both property and name attributes on <meta> tags, enabling extraction of standard <meta name="description"> tags in addition to Open Graph <meta property="..."> tags.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Hopping through the meta maze,
Found descriptions hiding in the haze,
Both name and property now we see,
Every hidden tag is finally free!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: support name attribute when extracting HTML meta tags' clearly and specifically describes the main change: adding support for the name attribute alongside property attribute in meta tag extraction.
Linked Issues check ✅ Passed The PR implements the exact objective from issue #5821: updating extractMetaProperty to check both attr.Key == 'property' and attr.Key == 'name' for meta tag extraction.
Out of Scope Changes check ✅ Passed The PR contains only the one-line change to plugin/httpgetter/html_meta.go needed to support the name attribute, with no extraneous modifications outside the stated objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

HTML meta description not extracted when using name attribute

1 participant