Skip to content
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

Escaped typography markup in URL autocomplete (Gutenberg) #245

Open
strarsis opened this issue Mar 31, 2019 · 11 comments
Open

Escaped typography markup in URL autocomplete (Gutenberg) #245

strarsis opened this issue Mar 31, 2019 · 11 comments
Labels
wp_core_bug A bug in WordPress Core

Comments

@strarsis
Copy link

strarsis commented Mar 31, 2019

Issue Overview

In Gutenberg editor the URL autocomplete for links shows escaped markup for
typography (e.g. <span class="amp">&</span>).
Either the raw HTML markup should be somehow injected (so it is not escaped) or
the page names shouldn't be filtered at all.

Steps to Reproduce (for bugs)

  1. Install + activate wp-typography plugin.
  2. Create a page that contains text in its title that wp-typography should
    process (& is a good example as this should be handled by default).
  3. Open a page in Gutenberg editor.
  4. Highlight text in editor and select the link button.
  5. In autocomplete, the page title should appear with escaped markup (HTML visible).
  • WordPress 5.1.1
  • wp-typography 5.5.4
  • Recent Chrome

Expected Behavior

No escaped HTML in URL autocompletion.

Current Behavior

Escaped HTML in URL autocompletion.

Possible Solution

  • Skip page title filter for URL autocomplete.
  • Inject raw HTML into page title instead which is not escaped (if possible at all).

Related Issues and/or PRs

#229

@mundschenk-at
Copy link
Owner

That's a Gutenberg bug. The REST-API search endpoint intentionally uses get_the_title() to retrieve the "rendered" title attribute. They should either strip the tags themselves or not escape the value.

@strarsis
Copy link
Author

@mundschenk-at: Would you recommend that I create an issue in the Gutenberg issue tracker for this?

@mundschenk-at
Copy link
Owner

Only if it still happens with the current development release of the Gutenberg plugin, otherwise it should be reported in the WordPress.org trac. I can't say how quickly it will be fixed (so I may create a workaround in the next release anyway), but it should be reported there.

@mundschenk-at
Copy link
Owner

@strarsis Have you opened a ticket?

@strarsis
Copy link
Author

@mundschenk-at: No, I haven't yet. I have been unsure whether you or me should create it. 😸

@mundschenk-at
Copy link
Owner

@strarsis Feel free to create the ticket. I'll comment with any follow-up information.

@strarsis
Copy link
Author

@strarsis
Copy link
Author

strarsis commented Mar 1, 2020

Now I encountered this issue, too, in a different context. I use the_title filter to add something to the markup that the Latest Posts Gutenberg core block uses (server-side rendering). In the autocomplete this markup crops up, even when using if(is_admin()) return $title; // skip.

@mundschenk-at
Copy link
Owner

Probably because the REST API is its own thing, and Gutenberg uses the rendered attribute value from the JSON response.

@strarsis
Copy link
Author

strarsis commented Mar 2, 2020

@mundschenk-at: Any workaround for this until Gutenberg fixes this issue? I use the filter in the theme, it should not interfere with the backend.

@mundschenk-at
Copy link
Owner

mundschenk-at commented Apr 5, 2020

@mundschenk-at: Any workaround for this until Gutenberg fixes this issue? I use the filter in the theme, it should not interfere with the backend.

You can use the typo_content_filters filter to unset the heading filter and use \WP_Typography::filter( $title, true ) in your templates (where appropriate).

@mundschenk-at mundschenk-at added the wp_core_bug A bug in WordPress Core label Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wp_core_bug A bug in WordPress Core
2 participants