SocialLinksPattern drops list item text outside the links, and counts every mailto: as a social service

Đang mở
#6,308 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading SocialLinksPattern, especially the list conversion, service() and isSocialCluster() paths; the issue names no file path or test. Reproduce with the Markdown or HTML reduction in the issue, then check cases with text beside links and lists containing only mailto: links. Done means those cases preserve list text and mail-only lists are not converted to social links.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

When SocialLinksPattern accepts a ul/ol as a social cluster, it builds core/social-link blocks from the anchors and discards everything else in the list items. Any text beside the links is silently lost. And because service() returns mail for every mailto: URL, isSocialCluster() accepts any list of two or more items that each contain an email address.

Seen in php-transformer v0.27.0, through FormatBridge with Markdown input (GFM to HTML first). The result was real data loss in a knowledge base entry: a history list became two mail social links, and the history lines were gone.

Reduction

Markdown:

- <[email protected]>
- 16 Nov: replied <[email protected]>

or the equivalent HTML:

<ul>
<li><a href="mailto:[email protected]">[email protected]</a></li>
<li>16 Nov: replied <a href="mailto:[email protected]">[email protected]</a></li>
</ul>

Output (v0.27.0):

<!-- wp:social-links {"showLabels":true,"className":"blocks-engine-source-social-item-spacing"} -->
<ul class="wp-block-social-links has-visible-labels blocks-engine-source-social-item-spacing">
<!-- wp:social-link {"url":"mailto:[email protected]","service":"mail","label":"[email protected]"} /-->
<!-- wp:social-link {"url":"mailto:[email protected]","service":"mail","label":"[email protected]"} /-->
</ul>
<!-- /wp:social-links -->

The 16 Nov: replied text is gone. A list with social hosts behaves the same way (- Code on [GitHub](https://github.com/x) / - Toots on [Mastodon](https://mastodon.social/@x) loses "Code on" and "Toots on").

Relation to #5979

#5979 (closed) stops text-labelled links to social hosts being treated as icons, which may cover the reductions above in a newer release. But the underlying data loss remains for any list the pattern does accept, for example icon links or an explicitly named .social list whose items also hold other text.

Expected

  • A list whose items hold text outside their links is never lowered to core/social-links (or the pattern declines and the list converts as core/list). Social links can't hold that text, so accepting the list loses content.
  • A cluster made only of mailto: links isn't treated as social on its own. Email addresses are ordinary content far more often than a social-icon row.
  • If text must be dropped, it should at least be reported as a fallback rather than lost silently.

Workaround downstream

In LH Content Converter we now hide http/https/mailto hrefs inside lists from the transformer for Markdown input (placeholder URLs on .invalid) and restore them afterwards. We'll drop that once this is fixed.


AI disclosure: diagnosed and filed with Claude (Anthropic) via the LocalHero MCP tooling, reproduced against the live converter.

Ngôn ngữ chính
PHP
Star
28
Fork
5
Merge trung bình
2 giờ 59 phút
Pull request đã merge (30 ngày)
942

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Automattic/blocks-engine

Tất cả issue của Automattic/blocks-engine

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.