WordPress.org

Making WordPress.org

Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#2879 closed defect (fixed)

Regex for @see linking of hooks does not account for unencoded quotes

Reported by: coffee2code Owned by: coffee2code
Milestone: Priority: normal
Component: Developer Hub Keywords:
Cc:

Description

When using the @see notation to link to hooks, it is necessary to place single quotes around the hook name. In the context of function descriptions (the majority usage), those quotes are already encoded as HTML entities prior to handling by link_internal_element(). However, data stored in meta (such as hash param descriptions) are not encoded. Thus, regular single quotes must also be considered in the auto-link handling for hooks (which presumes quotes are encoded).

For example, comment_form() https://developer.wordpress.org/reference/functions/comment_form/:

It's $args argument is a hash parameter. The first element 'fields' references a hook properly as {@see 'comment_form_default_fields'} and that string is eventually passed unencoded to link_internal_element() where, due to the lack of quote encoding, it passes through to the fallback option of assuming it should link to a function.

Change History (2)

#1 @coffee2code
6 months ago

  • Owner set to coffee2code
  • Resolution set to fixed
  • Status changed from new to closed

In 5577:

developer.wordpress.org: Change regex for @see linking of hooks to also check for unencoded quotes.

In the context of descriptions, the quotes around hook names are already encoded as HTML entities prior to handling by link_internal_element(). However, data stored in meta (such as hash param descriptions) are not encoded so regular single quotes must also be considered.

Example: https://developer.wordpress.org/reference/functions/comment_form/

Fixes #2879.

#2 @DrewAPicture
6 months ago

Nice catch!

Note: See TracTickets for help on using tickets.