Ticket #2980: patch.diff

File patch.diff, 4.4 KB (added by ecb29, 6 years ago)

Patch diff

Line 
1*** C:\Documents and Settings\Elliott Back\My Documents\Website\wos_1.1.2\www\test2\wp-includes\functions-formatting.php        Fri May 26 17:27:34 2006
2--- C:\Documents and Settings\Elliott Back\My Documents\Website\wos_1.1.2\www\test\wp-includes\functions-formatting.php Thu Jul 27 11:06:17 2006
3***************
4*** 1,49 ****
5  <?php
6 
7  function wptexturize($text) {
8        $output = '';
9!       // Capture tags and everything inside them
10!       $textarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
11!       $stop = count($textarr); $next = true; // loop stuff
12!       for ($i = 0; $i < $stop; $i++) {
13                $curl = $textarr[$i];
14!
15!               if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
16!                       $curl = str_replace('---', '&#8212;', $curl);
17!                       $curl = str_replace(' -- ', ' &#8212; ', $curl);
18!                       $curl = str_replace('--', '&#8211;', $curl);
19!                       $curl = str_replace('xn&#8211;', 'xn--', $curl);
20!                       $curl = str_replace('...', '&#8230;', $curl);
21!                       $curl = str_replace('``', '&#8220;', $curl);
22!
23!                       // This is a hack, look at this more later. It works pretty well though.
24!                       $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
25!                       $cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
26!                       $curl = str_replace($cockney, $cockneyreplace, $curl);
27!
28!                       $curl = preg_replace("/'s/", '&#8217;s', $curl);
29!                       $curl = preg_replace("/'(\d\d(?:&#8217;|')?s)/", "&#8217;$1", $curl);
30!                       $curl = preg_replace('/(\s|\A|")\'/', '$1&#8216;', $curl);
31!                       $curl = preg_replace('/(\d+)"/', '$1&#8243;', $curl);
32!                       $curl = preg_replace("/(\d+)'/", '$1&#8242;', $curl);
33!                       $curl = preg_replace("/(\S)'([^'\s])/", "$1&#8217;$2", $curl);
34!                       $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1&#8220;$2', $curl);
35!                       $curl = preg_replace('/"(\s|\S|\Z)/', '&#8221;$1', $curl);
36!                       $curl = preg_replace("/'([\s.]|\Z)/", '&#8217;$1', $curl);
37!                       $curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl);
38!                       $curl = str_replace("''", '&#8221;', $curl);
39!                       
40!                       $curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $curl);
41!
42!               } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
43!                       // strstr is fast
44!                       $next = false;
45!               } else {
46!                       $next = true;
47!               }
48!               $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$1', $curl);
49!               $output .= $curl;
50        }
51        return $output;
52  }
53 
54--- 1,36 ----
55  <?php
56 
57  function wptexturize($text) {
58+       $next = true;
59        $output = '';
60!       $curl = '';
61!       $textarr = preg_split('/(<.*>)/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
62!       $stop = count($textarr);
63!       
64!       for($i = 0; $i < $stop; $i++){
65                $curl = $textarr[$i];
66!               
67!       if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
68!               // static strings
69!               $static_characters = array('&#8212;', ' &#8212; ', '&#8211;', 'xn--', '&#8230;', '&#8220;', '\'tain\'t', '\'twere', '\'twas', '\'tis', '\'twill', '\'til', '\'bout', '\'nuff', '\'round', '\'cause', '\'s', '\'\'', ' (tm)');
70!               $static_replacements = array('---', ' -- ', '--', 'xn&#8211;', '...', '``', '&#8217;tain&#8217;t', '&#8217;twere', '&#8217;twas', '&#8217;tis', '&#8217;twill', '&#8217;til', '&#8217;bout', '&#8217;nuff', '&#8217;round', '&#8217;cause', '&#8217;s', '&#8221;', ' &#8482;');
71!               $curl = str_replace($static_characters, $static_replacements, $curl);
72!   
73!               // regular expressions
74!               $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/');
75!               $dynamic_replacements = array('&#8217;$1','$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1&#8220;$2', '&#8221;$1', '&#8217;$1', '$1&#215;$2');
76!               $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
77!       } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
78!               // strstr is fast
79!               $next = false;
80!       } else {
81!               $next = true;
82!       }
83!               
84!       $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$1', $curl);
85!       $output .= $curl;
86        }
87+       
88        return $output;
89  }
90