Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#54698 closed enhancement (fixed)

Add 'ruby' tag and its friends to kses

Reported by: upsuper's profile upsuper Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.0 Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch commit add-to-field-guide
Focuses: Cc:

Description

<ruby> element and its friends are used to attach annotation text onto a piece of text, like https://www.w3.org/TR/css-ruby-1/images/ruby-context.png

It is especially commonly used in Japanese content, but it can also been seen on content of other languages like Chinese.

The set of elements to enable such functionality consists of <ruby>, <rt>, and <rp> in the HTML Standard, while some browsers (like Firefox) also supports additional ones <rb> and <rtc> for more advanced formatting, which are not yet included in the official HTML spec, but can be found in a W3C extension.

These elements are purely presentational, and don't have any special functionality, and thus should not have any security implications for being added to $allowedposttags. Actually it seems that wordpress.com already supports them, while a local build doesn't.

Attachments (2)

54698.patch (446 bytes) - added by mukesh27 2 years ago.
54698.diff (1.5 KB) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (13)

This ticket was mentioned in PR #2086 on WordPress/wordpress-develop by upsuper.


2 years ago
#1

  • Keywords has-patch added

This PR adds the several tags related to ruby text to kses, so that they can be used without unfiltered_html rights in post content.

Trac ticket: https://core.trac.wordpress.org/ticket/54698

#2 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 6.0

@mukesh27
2 years ago

#3 follow-up: @mukesh27
2 years ago

Hi there!

Thanks for the ticket and patch.

I updated the patch 54698.patch with parent-child elements hierarchy because <ruby> is the main parent for all the other elements.

For example:

<ruby><rb>base<rt>annotation</ruby>
<ruby>
  <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang=fr><rt>Cœur</rt></rtc>
  <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang=fr><rt>Trèfle</rt></rtc>
  <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang=fr><rt>Étoile</rt></rtc>
</ruby>

#4 in reply to: ↑ 3 ; follow-up: @upsuper
2 years ago

Replying to mukesh27:

I updated the patch 54698.patch with parent-child elements hierarchy because <ruby> is the main parent for all the other elements.

Indeed that <ruby> is the ancestor for all the other elements, but I'm confused by your patch. It seems to me that the second level of arrays are for attributes of the tag, not possible child tags, and <table> which has a similar structure as <ruby> doesn't contain any such child element either. If the same idea holds, <table> should include <caption>, <tbody>, <thead>, <tfoot>, <tr>, <td>, <th>, <colgroup>, <col>. Also, <summary> can only meaningfully be inside <details>, and <li> only in <ol> and <ul>, <track> only in <video> and <audio>, etc. But none of them seems to be listed in the way your patch shows.

Could you clarify?

#5 @upsuper
2 years ago

Any update here?

@SergeyBiryukov
2 years ago

#6 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#7 in reply to: ↑ 4 @SergeyBiryukov
2 years ago

  • Keywords commit added

Replying to upsuper:

Indeed that <ruby> is the ancestor for all the other elements, but I'm confused by your patch. It seems to me that the second level of arrays are for attributes of the tag, not possible child tags, and <table> which has a similar structure as <ruby> doesn't contain any such child element either.

You're right, the first PR here appears to be correct as is.

54698.diff adds a unit test. This can be committed after #54699, as the test relies on the changes from that ticket.

The set of elements to enable such functionality consists of <ruby>, <rt>, and <rp> in the HTML Standard, while some browsers (like Firefox) also supports additional ones <rb> and <rtc> for more advanced formatting, which are not yet included in the official HTML spec, but can be found in a W3C extension.

I'm not 100% sure we should add elements that are not in the official HTML spec, but don't see any harm in adding the <rb> and <rtc> tags either. If anyone has strong feelings either way, please comment :)

#8 @SergeyBiryukov
2 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 52969:

KSES: Add support for <ruby> and related elements.

<ruby> element and its friends are used to attach annotation text onto a piece of text. This is especially commonly used in Japanese content, but it can also been seen in content of other languages like Chinese.

The set of elements to enable such functionality consists of <ruby>, <rt>, and <rp> in the HTML Standard, while some browsers (like Firefox) additionally support <rb> and <rtc> for more advanced formatting, which are not yet included in the official HTML spec, but can be found in a W3C extension.

Props upsuper, mukesh27, SergeyBiryukov.
Fixes #54698.

#10 @milana_cap
2 years ago

  • Keywords needs-dev-note added

#11 @milana_cap
2 years ago

  • Keywords add-to-field-guide added; needs-dev-note removed
Note: See TracTickets for help on using tickets.