Changeset 45989
- Timestamp:
- 09/04/2019 05:22:29 PM (4 years ago)
- Location:
- branches/5.2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.2
-
branches/5.2/src/js/_enqueues/admin/post.js
r44896 r45989 796 796 797 797 // Update "Status:" to currently selected status. 798 $('#post-status-display').html($('option:selected', postStatus).text()); 798 $('#post-status-display').text( 799 wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() ) // Remove any potential tags from post status text. 800 ); 799 801 800 802 // Show or hide the "Save Draft" button. -
branches/5.2/src/js/_enqueues/wp/a11y.js
r43347 r45989 28 28 clear(); 29 29 30 // Ensureonly text is sent to screen readers.31 message = $( '<p>' ).html( message ).text();30 // Remove HTML tags, ensuring only text is sent to screen readers. 31 message = wp.sanitize.stripTagsAndEncodeText( message ); 32 32 33 33 /* -
branches/5.2/src/js/_enqueues/wp/customize/nav-menus.js
r45870 r45989 3457 3457 function displayNavMenuName( name ) { 3458 3458 name = name || ''; 3459 name = $( '<div>' ).text( name ).html(); // Emulate esc_html() which is used in wp-admin/nav-menus.php.3459 name = wp.sanitize.stripTagsAndEncodeText( name ); // Remove any potential tags from name. 3460 3460 name = $.trim( name ); 3461 3461 return name || api.Menus.data.l10n.unnamed; -
branches/5.2/src/js/_enqueues/wp/sanitize.js
r43347 r45989 24 24 text = text || ''; 25 25 26 return text 27 .replace( /<!--[\s\S]*?(-->|$)/g, '' ) 28 .replace( /<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/ig, '' ) 29 .replace( /<\/?[a-z][\s\S]*?(>|$)/ig, '' ); 26 // Do the replacement. 27 var _text = text 28 .replace( /<!--[\s\S]*?(-->|$)/g, '' ) 29 .replace( /<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/ig, '' ) 30 .replace( /<\/?[a-z][\s\S]*?(>|$)/ig, '' ); 31 32 // If the initial text is not equal to the modified text, 33 // do the search-replace again, until there is nothing to be replaced. 34 if ( _text !== text ) { 35 return wp.sanitize.stripTags( _text ); 36 } 37 38 // Return the text with stripped tags. 39 return _text; 30 40 }, 31 41 … … 42 52 43 53 try { 44 textarea. innerHTML= _text;54 textarea.textContent = _text; 45 55 _text = wp.sanitize.stripTags( textarea.value ); 46 56 } catch ( er ) {} -
branches/5.2/src/js/_enqueues/wp/updates.js
r44417 r45989 263 263 if ( 'undefined' !== typeof response.debug && window.console && window.console.log ) { 264 264 _.map( response.debug, function( message ) { 265 window.console.log( $( '<p />' ).html( message ).text() ); 265 // Remove all HTML tags and write a message to the console. 266 window.console.log( wp.sanitize.stripTagsAndEncodeText( message ) ); 266 267 } ); 267 268 } -
branches/5.2/src/wp-includes/script-loader.php
r45844 r45989 880 880 ); 881 881 882 $scripts->add( 'wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array( 'jquery' ), false, 1 ); 882 $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 ); 883 884 $scripts->add( 'wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array( 'jquery', 'wp-sanitize' ), false, 1 ); 883 885 884 886 $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 ); … … 1483 1485 $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); 1484 1486 1485 $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu' ), false, 1 );1487 $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu', 'wp-sanitize' ), false, 1 ); 1486 1488 $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); 1487 1489 … … 1581 1583 ); 1582 1584 1583 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y' ), false, 1 );1585 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize' ), false, 1 ); 1584 1586 did_action( 'init' ) && $scripts->localize( 1585 1587 'post', … … 1694 1696 $scripts->set_translations( 'site-health' ); 1695 1697 1696 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );1698 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 ); 1697 1699 did_action( 'init' ) && $scripts->localize( 1698 1700 'updates', -
branches/5.2/tests/phpunit/tests/dependencies/scripts.php
r44744 r45989 693 693 694 694 $ver = get_bloginfo( 'version' ); 695 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5B%5D=jquery-core,jquery-migrate,wp- a11y&ver={$ver}'></script>\n";695 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5B%5D=jquery-core,jquery-migrate,wp-sanitize,wp-a11y&ver={$ver}'></script>\n"; 696 696 $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n"; 697 697 $expected .= "<script type='text/javascript' src='http://example.com'></script>\n"; -
branches/5.2/tests/qunit/index.html
r45147 r45989 77 77 <script src="../../build/wp-includes/js/customize-models.js"></script> 78 78 <script src="../../build/wp-includes/js/shortcode.js"></script> 79 + <script src="../../build/wp-includes/js/wp-sanitize.js"></script> 79 80 <script src="../../build/wp-admin/js/customize-controls.js"></script> 80 81 <script src="../../build/wp-includes/js/api-request.js"></script>
Note: See TracChangeset
for help on using the changeset viewer.