X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/874d2a2f468a0d1e69aab49b1fe2d9d79d3e1142..899389d1e4043331309c0433543419258b230b60:/wp-includes/formatting.php
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index e79043bc..acdc3d78 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -11,13 +11,13 @@
* Replaces common plain text characters into formatted entities
*
* As an example,
- *
- * 'cause today's effort makes it worth tomorrow's "holiday"...
- *
+ *
+ * 'cause today's effort makes it worth tomorrow's "holiday" ...
+ *
* Becomes:
- *
- * ’cause today’s effort makes it worth tomorrow’s “holiday”…
- *
+ *
+ * ’cause today’s effort makes it worth tomorrow’s “holiday” …
+ *
* Code within certain html blocks are skipped.
*
* @since 0.71
@@ -86,11 +86,11 @@ function wptexturize($text, $reset = false) {
// if a plugin has provided an autocorrect array, use it
if ( isset($wp_cockneyreplace) ) {
- $cockney = array_keys($wp_cockneyreplace);
- $cockneyreplace = array_values($wp_cockneyreplace);
+ $cockney = array_keys( $wp_cockneyreplace );
+ $cockneyreplace = array_values( $wp_cockneyreplace );
} elseif ( "'" != $apos ) { // Only bother if we're doing a replacement.
- $cockney = array( "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause" );
- $cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause" );
+ $cockney = array( "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause", "'em" );
+ $cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause", $apos . "em" );
} else {
$cockney = $cockneyreplace = array();
}
@@ -174,9 +174,9 @@ function wptexturize($text, $reset = false) {
// Dashes and spaces
$dynamic[ '/---/' ] = $em_dash;
- $dynamic[ '/(?<=' . $spaces . ')--(?=' . $spaces . ')/' ] = $em_dash;
+ $dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash;
$dynamic[ '/(?)' // Dash not followed by end of comment.
. '[^\-]*+' // Consume non-dashes.
. ')*+' // Loop possessively.
- . '-->'; // End of comment.
-
- $regex = '/(' // Capture the entire match.
- . '<' // Find start of element.
- . '(?(?=!--)' // Is this a comment?
- . $comment_regex // Find end of comment
- . '|'
- . '[^>]+>' // Find end of element
- . ')'
+ . '(?:-->)?'; // End of comment. If not found, match all input.
+
+ $shortcode_regex =
+ '\[' // Find start of shortcode.
+ . '[\/\[]?' // Shortcodes may begin with [/ or [[
+ . $tagregexp // Only match registered shortcodes, because performance.
+ . '(?:'
+ . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical.
. '|'
- . '\[' // Find start of shortcode.
- . '[\/\[]?' // Shortcodes may begin with [/ or [[
- . $tagregexp // Only match registered shortcodes, because performance.
- . '(?:'
- . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical.
- . '|'
- . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >.
- . ')*+' // Possessive critical.
- . '\]' // Find end of shortcode.
- . '\]?' // Shortcodes may end with ]]
+ . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >.
+ . ')*+' // Possessive critical.
+ . '\]' // Find end of shortcode.
+ . '\]?'; // Shortcodes may end with ]]
+
+ $regex =
+ '/(' // Capture the entire match.
+ . '<' // Find start of element.
+ . '(?(?=!--)' // Is this a comment?
+ . $comment_regex // Find end of comment.
+ . '|'
+ . '[^>]*>' // Find end of element.
+ . ')'
+ . '|'
+ . $shortcode_regex // Find shortcodes.
. ')/s';
$textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
@@ -242,30 +246,31 @@ function wptexturize($text, $reset = false) {
foreach ( $textarr as &$curl ) {
// Only call _wptexturize_pushpop_element if $curl is a delimiter.
$first = $curl[0];
- if ( '<' === $first && '>' === substr( $curl, -1 ) ) {
- // This is an HTML delimiter.
+ if ( '<' === $first && '