WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Uncaught SyntaxError: Unexpected token & on admin area (2 posts)

  1. Gabor Javorszky
    Member
    Posted 1 year ago #

    WordPress version: 3.5
    WordPress SEO version: 1.3.4.1

    I did this: Activated the plugin

    I expected the plugin to do this: Run smoothly

    Instead it did this: Produced this error in the browser's console:
    Uncaught SyntaxError: Unexpected token &.

    I have disabled all other plugins and switched back to both twenty-eleven and twenty-twelve themes to test it. The error persists, but only when viewing the administration area. Here's the problematic code section:

    <script type="text/javascript">
    		//<![CDATA[
    		(function ($) {
    			var wpseo_pointer_options = {"content":"<h3>Help improve WordPress SEO<\/h3><p>You've just installed WordPress SEO by Yoast. Please helps us improve it by allowing us to gather anonymous usage stats so we know which configurations, plugins and themes to test with.<\/p>","position":{"edge":"top","align":"center"}}, setup;
    
    			wpseo_pointer_options = $.extend(wpseo_pointer_options, {
    				buttons:function (event, t) {
    					button = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + 'Do not allow tracking' + '</a>');
    					button.bind('click.pointer', function () {
    						t.element.pointer('close');
    					});
    					return button;
    				},
    				close:function () {
    				}
    			});
    
    			setup = function () {
    				$('#wpadminbar').pointer(wpseo_pointer_options).pointer('open');
    									jQuery('#pointer-close').after('<a id="pointer-primary" class="button-primary">' + 'Allow tracking' + '</a>');
    					jQuery('#pointer-primary').click(function () {
    						document.location=&quot;http://server.com/site/wp-admin/admin.php?page=wpseo_dashboard&allow_tracking=yes&nonce=972bc26082&quot;;					});
    Uncaught SyntaxError: Unexpected token &
    					jQuery('#pointer-close').click(function () {
    													document.location=&quot;http://server.com/site/wp-admin/admin.php?page=wpseo_dashboard&allow_tracking=no&nonce=972bc26082&quot;;												});
    								};
    
    			if (wpseo_pointer_options.position && wpseo_pointer_options.position.defer_loading)
    				$(window).bind('load.wp-pointers', setup);
    			else
    				$(document).ready(setup);
    		})(jQuery);
    		//]]>
    	</script>

    The double quotes around the url get escaped for some reason, and they should not be esacaped.

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. TheDeadMedic
    Member
    Posted 1 year ago #

    Was just about to post this too - troublemaker is WPSEO_Pointers::print_scripts, lines 233 & 239, which applies esc_js() to the button function parameters.

    Escaping should be performed (where necessary) as the caller builds the JS code, and then printed as-is by print_scripts().

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic