(OBJ) symbol in WordPress URL?

Viewed 1978

I have a question about a WordPress URL in Google Chrome 94.0.4606.81:

I was reading a WordPress article recently and noticed that there is an  (OBJ) symbol in the URL. The symbol is also in the webpage title.

Take Ownership and Select Owner


Question:

What is the purpose of the  (OBJ) symbol -- and how is it possible that it has been included in a URL?

3 Answers

Honestly, I don't know what nature is this copy/paste issue in WP, and the "Object Replacement Character"

To avoid appearing this character it's enough to use Ctrl+Shift+V shortcut while pasting into WP post title field, means: Paste Text Without Formatting.

If you want to be sure in protecting the post slug (means: post URL) you can use the snippet in your functions.php:

/**
 * Remove the strange [OBJ] character in the post slug
 * See: https://github.com/WordPress/gutenberg/issues/38637
 */
add_filter("wp_unique_post_slug", function($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug) {
    return preg_replace('/(%ef%bf%bc)|(efbfbc)|[^\w-]/', '', $slug);
}, 10, 6);

preg_replace function searches here for string "%ef%bf%bc" or "efbfbc" (UTF-8 - hex encoded OBJ character) OR any character that IS NOT base alphanumeric character or dash character – to delete.

Since you've mentioned it also made into the title: I use this to filter the title on save to remove these special characters.

function sbnc_filter_title($title) {

    // Concatenate separate diacritics into one character if we can
    if ( function_exists('normalizer_normalize') && strlen( normalizer_normalize( $title ) ) < strlen( $title ) ) {
        $title = normalizer_normalize( $title );
    }

    // Replace no-break-space with regular space
    $title = preg_replace( '/\x{00A0}/u', ' ', $title );
    
    // Remove whitespaces from the ends
    $title = trim($title);

    // Remove any invisible and control characters
    $title = preg_replace('/[^\x{0020}-\x{007e}\x{00a1}-\x{FFEF}]/u', '', $title);

    return $title;
}
add_filter('title_save_pre', 'sbnc_filter_title');

Please note that you may need to extend set of allowed UTF range in the preg_replace call based on the languages you support. The range in the example should suit most languages actively used in the word, but if you may write article titles that include archaic scripts like Linear-B, gothic etc. you may need to extend the ranges.

It seems like you got this symbol in the title field of the article. You can remove it from there. If you don't see it select everything in the field with ctrl + a and write the title new.

Related