Support » Plugin: Shortcode in Menus » Causes URLs to be amended in undesired ways

  • Resolved Lee Willis

    (@leewillis77)



    Hi;

    This plugin attaches to the clean_url filter, and in doing so causes the output of esc_url() to be changed in ways that can cause issues (XML validation failures etc if the output is used in an XML attribute)

    For example, without this plugin, the following code:

    esc_url('http://woocommerce.dev?test=one&another=arg');

    returns:

    http://woocommerce.dev?test=one& #038another=arg

    With this plugin activated, the same code returns:

    http://woocommerce.dev?test=one&another=arg

    https://wordpress.org/plugins/shortcode-in-menus/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Lee Willis

    (@leewillis77)

    [Ignore the space between the & and the # it was the only way I could get the forum not to swallow the text]

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    Lee Willis

    I’ll check out this issue tomorrow and thanks for providing detailed info regarding this bug, it’ll save me a lot of time.

    In the meantime if you figure out a way to fix this, I’ll be happy to merge your patch in the plugin.

    Lee Willis

    (@leewillis77)

    Hi;

    Thanks for the quick reply!

    So – the code “at fault” is this code here:

    // filter the output when shortcode is saved using custom links, for legacy support
    add_filter( 'clean_url', array( $this, 'display_shortcode' ), 1, 3 );

    Removing that line “fixes” the problem, but not sure what it might break. I’m not familiar enough with the plugin’s working to comment really – but it seems strange – is a URL ever going to contain a shortcode!?

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    Lee Willis

    Removing those lines will cause the plugin to break the way it used to work and it will break a lot of sites. So I will need to figure out a way to conditionally implement that filter instead of removing it.

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    Lee Willis

    Just released a new version, with the fix to the issue you’re facing, update to version 3.1 for the patch.
    Once again, thanks for finding the bug and reporting it here, as well as helping out in its resolution.

    Lee Willis

    (@leewillis77)

    That’s perfect – resolves my issue perfectly. Thanks for the speedy support!

    Plugin Author Gagan Deep Singh

    (@gagan0123)

    Lee Willis

    Always welcome 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Causes URLs to be amended in undesired ways’ is closed to new replies.