Changeset 28223
- Timestamp:
- 05/01/2014 03:36:27 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/shortcode.js
r26228 r28223 38 38 // and increment the index accordingly. 39 39 if ( match[1] ) { 40 result. match = result.match.slice( 1 );40 result.content = result.content.slice( 1 ); 41 41 result.index++; 42 42 } … … 44 44 // If we matched a trailing `]`, strip it from the match. 45 45 if ( match[7] ) { 46 result. match = result.match.slice( 0, -1 );46 result.content = result.content.slice( 0, -1 ); 47 47 } 48 48 -
trunk/tests/qunit/wp-includes/js/shortcode.js
r27371 r28223 56 56 result = wp.shortcode.next( 'foo', 'this has the [[foo param="foo"]] shortcode' ); 57 57 equal( result, undefined, 'foo shortcode not found when escaped with params' ); 58 }); 59 60 test( 'next() should find shortcodes that are incorrectly escaped by newlines', function() { 61 var result; 62 63 result = wp.shortcode.next( 'foo', 'this has the [\n[foo]] shortcode' ); 64 equal( result.index, 15, 'shortcode found when incorrectly escaping the start of it' ); 65 66 result = wp.shortcode.next( 'foo', 'this has the [[foo]\n] shortcode' ); 67 equal( result.index, 14, 'shortcode found when incorrectly escaping the end of it' ); 68 }); 69 70 test( 'next() should still work when there are not equal ammounts of square brackets', function() { 71 var result; 72 73 result = wp.shortcode.next( 'foo', 'this has the [[foo] shortcode' ); 74 equal( result.index, 14, 'shortcode found when there are offset square brackets' ); 75 76 result = wp.shortcode.next( 'foo', 'this has the [foo]] shortcode' ); 77 equal( result.index, 13, 'shortcode found when there are offset square brackets' ); 58 78 }); 59 79 … … 124 144 }); 125 145 146 test( 'replace() should replace improperly escaped shortcodes that include newlines', function() { 147 var result; 148 149 result = wp.shortcode.replace( 'foo', 'this [foo] has the [[foo param="bar"]\n] shortcode ', shortcodeReplaceCallback ); 150 equal( result, 'this bar has the [bar\n] shortcode ', 'escaping with newlines should not actually escape the content' ); 151 152 result = wp.shortcode.replace( 'foo', 'this [foo] has the [\n[foo param="bar"]] shortcode ', shortcodeReplaceCallback ); 153 equal( result, 'this bar has the [\nbar] shortcode ', 'escaping with newlines should not actually escape the content' ); 154 }); 155 126 156 test( 'replace() should not replace the shortcode when it is an incomplete match', function() { 127 157 var result;
Note: See TracChangeset
for help on using the changeset viewer.