diff options
Diffstat (limited to 'lib/htmlawed/htmLawedTest.php')
-rwxr-xr-x | lib/htmlawed/htmLawedTest.php | 1354 |
1 files changed, 677 insertions, 677 deletions
diff --git a/lib/htmlawed/htmLawedTest.php b/lib/htmlawed/htmLawedTest.php index 6475bc8..dfbfb27 100755 --- a/lib/htmlawed/htmLawedTest.php +++ b/lib/htmlawed/htmLawedTest.php | |||
@@ -1,677 +1,677 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | /* | 3 | /* |
4 | htmLawedTest.php, 17 May 2017 | 4 | htmLawedTest.php, 17 May 2017 |
5 | To test htmLawed | 5 | To test htmLawed |
6 | Copyright Santosh Patnaik | 6 | Copyright Santosh Patnaik |
7 | Dual licensed with LGPL 3 and GPL 2+ | 7 | Dual licensed with LGPL 3 and GPL 2+ |
8 | A PHP Labware internal utility - www.bioinformatics.org/phplabware/internal_utilities/htmLawed | 8 | A PHP Labware internal utility - www.bioinformatics.org/phplabware/internal_utilities/htmLawed |
9 | 9 | ||
10 | Test htmLawed; user provides text input; input and processed input are shown as highlighted code and rendered HTML; also shown are execution time and peak memory usage | 10 | Test htmLawed; user provides text input; input and processed input are shown as highlighted code and rendered HTML; also shown are execution time and peak memory usage |
11 | */ | 11 | */ |
12 | 12 | ||
13 | // config | 13 | // config |
14 | $_errs = 0; // display PHP errors | 14 | $_errs = 0; // display PHP errors |
15 | $_limit = 12000; // input character limit | 15 | $_limit = 12000; // input character limit |
16 | $_hlimit = 2000; // input character limit for showing hexdumps | 16 | $_hlimit = 2000; // input character limit for showing hexdumps |
17 | $_hilite = 1; // 0 turns off slow Javascript-based code-highlighting, e.g., if $_limit is high | 17 | $_hilite = 1; // 0 turns off slow Javascript-based code-highlighting, e.g., if $_limit is high |
18 | $_w3c_validate = 1; // 1 to show buttons to send input/output to w3c validator | 18 | $_w3c_validate = 1; // 1 to show buttons to send input/output to w3c validator |
19 | $_sid = 'sid'; // session name; alphanum. | 19 | $_sid = 'sid'; // session name; alphanum. |
20 | $_slife = 30; // session life in min. | 20 | $_slife = 30; // session life in min. |
21 | 21 | ||
22 | // errors | 22 | // errors |
23 | error_reporting(E_ALL | (defined('E_STRICT') ? E_STRICT : 0)); | 23 | error_reporting(E_ALL | (defined('E_STRICT') ? E_STRICT : 0)); |
24 | ini_set('display_errors', $_errs); | 24 | ini_set('display_errors', $_errs); |
25 | 25 | ||
26 | // session | 26 | // session |
27 | session_name($_sid); | 27 | session_name($_sid); |
28 | session_cache_limiter('private'); | 28 | session_cache_limiter('private'); |
29 | session_cache_expire($_slife); | 29 | session_cache_expire($_slife); |
30 | ini_set('session.gc_maxlifetime', $_slife * 60); | 30 | ini_set('session.gc_maxlifetime', $_slife * 60); |
31 | ini_set('session.use_only_cookies', 1); | 31 | ini_set('session.use_only_cookies', 1); |
32 | ini_set('session.cookie_lifetime', 0); | 32 | ini_set('session.cookie_lifetime', 0); |
33 | session_start(); | 33 | session_start(); |
34 | if(!isset($_SESSION['token'])){ | 34 | if(!isset($_SESSION['token'])){ |
35 | $_SESSION['token'] = md5(uniqid(rand(), 1)); | 35 | $_SESSION['token'] = md5(uniqid(rand(), 1)); |
36 | } | 36 | } |
37 | 37 | ||
38 | // slashes | 38 | // slashes |
39 | if(get_magic_quotes_gpc()){ | 39 | if(get_magic_quotes_gpc()){ |
40 | foreach($_POST as $k => $v){ | 40 | foreach($_POST as $k => $v){ |
41 | $_POST[$k] = stripslashes($v); | 41 | $_POST[$k] = stripslashes($v); |
42 | } | 42 | } |
43 | ini_set('magic_quotes_gpc', 0); | 43 | ini_set('magic_quotes_gpc', 0); |
44 | } | 44 | } |
45 | if(get_magic_quotes_runtime()){ | 45 | if(get_magic_quotes_runtime()){ |
46 | set_magic_quotes_runtime(0); | 46 | set_magic_quotes_runtime(0); |
47 | } | 47 | } |
48 | 48 | ||
49 | $_POST['enc'] = (isset($_POST['enc']) and preg_match('`^[-\w]+$`', $_POST['enc'])) ? $_POST['enc'] : 'utf-8'; | 49 | $_POST['enc'] = (isset($_POST['enc']) and preg_match('`^[-\w]+$`', $_POST['enc'])) ? $_POST['enc'] : 'utf-8'; |
50 | 50 | ||
51 | // token for anti-CSRF | 51 | // token for anti-CSRF |
52 | if(count($_POST)){ | 52 | if(count($_POST)){ |
53 | if((empty($_GET['pre']) and ((!empty($_POST['token']) and !empty($_SESSION['token']) and $_POST['token'] != $_SESSION['token']) or empty($_POST[$_sid]) or $_POST[$_sid] != session_id() or empty($_COOKIE[$_sid]) or $_COOKIE[$_sid] != session_id())) or ($_POST[$_sid] != session_id())){ | 53 | if((empty($_GET['pre']) and ((!empty($_POST['token']) and !empty($_SESSION['token']) and $_POST['token'] != $_SESSION['token']) or empty($_POST[$_sid]) or $_POST[$_sid] != session_id() or empty($_COOKIE[$_sid]) or $_COOKIE[$_sid] != session_id())) or ($_POST[$_sid] != session_id())){ |
54 | $_POST = array('enc'=>'utf-8'); | 54 | $_POST = array('enc'=>'utf-8'); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | if(empty($_GET['pre'])){ | 57 | if(empty($_GET['pre'])){ |
58 | $_SESSION['token'] = md5(uniqid(rand(), 1)); | 58 | $_SESSION['token'] = md5(uniqid(rand(), 1)); |
59 | $token = $_SESSION['token']; | 59 | $token = $_SESSION['token']; |
60 | session_regenerate_id(1); | 60 | session_regenerate_id(1); |
61 | } | 61 | } |
62 | 62 | ||
63 | // compress | 63 | // compress |
64 | if(function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('`gzip|deflate`i', $_SERVER['HTTP_ACCEPT_ENCODING']) && !ini_get('zlib.output_compression')){ | 64 | if(function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('`gzip|deflate`i', $_SERVER['HTTP_ACCEPT_ENCODING']) && !ini_get('zlib.output_compression')){ |
65 | ob_start('ob_gzhandler'); | 65 | ob_start('ob_gzhandler'); |
66 | } | 66 | } |
67 | 67 | ||
68 | // HTM for unprocessed | 68 | // HTM for unprocessed |
69 | if(isset($_POST['inputH'])){ | 69 | if(isset($_POST['inputH'])){ |
70 | echo '<html><head><title>htmLawed test: HTML view of unprocessed input</title></head><body style="margin:0; padding: 0;"><p style="background-color: black; color: white; padding: 2px;"> Rendering of raw/unprocessed input without an HTML doctype or charset declaration <small><a style="color: white; text-decoration: none;" href="1" onclick="javascript:window.close(this); return false;">close window</a> | <a style="color: white; text-decoration: none;" href="htmLawedTest.php" onclick="javascript: window.open(\'htmLawedTest.php\', \'hlmain\'); window.close(this); return false;">htmLawed test page</a></small></p><div>', $_POST['inputH'], '</div></body></html>'; | 70 | echo '<html><head><title>htmLawed test: HTML view of unprocessed input</title></head><body style="margin:0; padding: 0;"><p style="background-color: black; color: white; padding: 2px;"> Rendering of raw/unprocessed input without an HTML doctype or charset declaration <small><a style="color: white; text-decoration: none;" href="1" onclick="javascript:window.close(this); return false;">close window</a> | <a style="color: white; text-decoration: none;" href="htmLawedTest.php" onclick="javascript: window.open(\'htmLawedTest.php\', \'hlmain\'); window.close(this); return false;">htmLawed test page</a></small></p><div>', $_POST['inputH'], '</div></body></html>'; |
71 | exit; | 71 | exit; |
72 | } | 72 | } |
73 | 73 | ||
74 | // HTM for processed | 74 | // HTM for processed |
75 | if(isset($_POST['outputH'])){ | 75 | if(isset($_POST['outputH'])){ |
76 | echo '<html><head><title>htmLawed test: HTML view of unprocessed input</title></head><body style="margin:0; padding: 0;"><p style="background-color: black; color: white; padding: 2px;"> Rendering of filtered/processed input without an HTML doctype or charset declaration <small><a style="color: white; text-decoration: none;" href="1" onclick="javascript:window.close(this); return false;">close window</a> | <a style="color: white; text-decoration: none;" href="htmLawedTest.php" onclick="javascript: window.open(\'htmLawedTest.php\', \'hlmain\'); window.close(this); return false;">htmLawed test page</a></small></p><div>', $_POST['outputH'], '</div></body></html>'; | 76 | echo '<html><head><title>htmLawed test: HTML view of unprocessed input</title></head><body style="margin:0; padding: 0;"><p style="background-color: black; color: white; padding: 2px;"> Rendering of filtered/processed input without an HTML doctype or charset declaration <small><a style="color: white; text-decoration: none;" href="1" onclick="javascript:window.close(this); return false;">close window</a> | <a style="color: white; text-decoration: none;" href="htmLawedTest.php" onclick="javascript: window.open(\'htmLawedTest.php\', \'hlmain\'); window.close(this); return false;">htmLawed test page</a></small></p><div>', $_POST['outputH'], '</div></body></html>'; |
77 | exit; | 77 | exit; |
78 | } | 78 | } |
79 | 79 | ||
80 | // main | 80 | // main |
81 | $_POST['text'] = isset($_POST['text']) ? $_POST['text'] : 'text to process; < '. $_limit. ' characters'. ($_hlimit ? ' (for binary hexdump view, < '. $_hlimit. ')' : ''); | 81 | $_POST['text'] = isset($_POST['text']) ? $_POST['text'] : 'text to process; < '. $_limit. ' characters'. ($_hlimit ? ' (for binary hexdump view, < '. $_hlimit. ')' : ''); |
82 | $do = (!empty($_POST[$_sid]) && isset($_POST['text'][0]) && !isset($_POST['text'][$_limit])) ? 1 : 0; | 82 | $do = (!empty($_POST[$_sid]) && isset($_POST['text'][0]) && !isset($_POST['text'][$_limit])) ? 1 : 0; |
83 | $limit_exceeded = isset($_POST['text'][$_limit]) ? 1 : 0; | 83 | $limit_exceeded = isset($_POST['text'][$_limit]) ? 1 : 0; |
84 | $pre_mem = memory_get_usage(); | 84 | $pre_mem = memory_get_usage(); |
85 | $validation = (!empty($_POST[$_sid]) and isset($_POST['w3c_validate'][0])) ? 1 : 0; | 85 | $validation = (!empty($_POST[$_sid]) and isset($_POST['w3c_validate'][0])) ? 1 : 0; |
86 | include './htmLawed.php'; | 86 | include './htmLawed.php'; |
87 | 87 | ||
88 | function format($t){ | 88 | function format($t){ |
89 | $t = "\n". str_replace(array("\t", "\r\n", "\r", '&', '<', '>', "\n"), array(' ', "\n", "\n", '&', '<', '>', "<span class=\"newline\">¬</span><br />\n"), $t); | 89 | $t = "\n". str_replace(array("\t", "\r\n", "\r", '&', '<', '>', "\n"), array(' ', "\n", "\n", '&', '<', '>', "<span class=\"newline\">¬</span><br />\n"), $t); |
90 | return str_replace(array('<br />', "\n ", ' '), array("\n<br />\n", "\n ", ' '), $t); | 90 | return str_replace(array('<br />', "\n ", ' '), array("\n<br />\n", "\n ", ' '), $t); |
91 | } | 91 | } |
92 | 92 | ||
93 | function hexdump($d){ | 93 | function hexdump($d){ |
94 | // Mainly by Aidan Lister <aidan@php.net>, Peter Waller <iridum@php.net> | 94 | // Mainly by Aidan Lister <aidan@php.net>, Peter Waller <iridum@php.net> |
95 | $hexi = ''; | 95 | $hexi = ''; |
96 | $ascii = ''; | 96 | $ascii = ''; |
97 | ob_start(); | 97 | ob_start(); |
98 | echo '<pre>'; | 98 | echo '<pre>'; |
99 | $offset = 0; | 99 | $offset = 0; |
100 | $len = strlen($d); | 100 | $len = strlen($d); |
101 | for($i=$j=0; $i<$len; $i++) | 101 | for($i=$j=0; $i<$len; $i++) |
102 | { | 102 | { |
103 | // Convert to hexidecimal | 103 | // Convert to hexidecimal |
104 | $hexi .= sprintf("%02X ", ord($d[$i])); | 104 | $hexi .= sprintf("%02X ", ord($d[$i])); |
105 | // Replace non-viewable bytes with '.' | 105 | // Replace non-viewable bytes with '.' |
106 | if(ord($d[$i]) >= 32){ | 106 | if(ord($d[$i]) >= 32){ |
107 | $ascii .= htmlspecialchars($d[$i]); | 107 | $ascii .= htmlspecialchars($d[$i]); |
108 | }else{ | 108 | }else{ |
109 | $ascii .= '.'; | 109 | $ascii .= '.'; |
110 | } | 110 | } |
111 | // Add extra column spacing | 111 | // Add extra column spacing |
112 | if($j == 7){ | 112 | if($j == 7){ |
113 | $hexi .= ' '; | 113 | $hexi .= ' '; |
114 | $ascii .= ' '; | 114 | $ascii .= ' '; |
115 | } | 115 | } |
116 | // Add row | 116 | // Add row |
117 | if(++$j == 16 || $i == $len-1){ | 117 | if(++$j == 16 || $i == $len-1){ |
118 | // Join the hexi / ascii output | 118 | // Join the hexi / ascii output |
119 | echo sprintf("%04X %-49s %s", $offset, $hexi, $ascii); | 119 | echo sprintf("%04X %-49s %s", $offset, $hexi, $ascii); |
120 | // Reset vars | 120 | // Reset vars |
121 | $hexi = $ascii = ''; | 121 | $hexi = $ascii = ''; |
122 | $offset += 16; | 122 | $offset += 16; |
123 | $j = 0; | 123 | $j = 0; |
124 | // Add newline | 124 | // Add newline |
125 | if ($i !== $len-1){ | 125 | if ($i !== $len-1){ |
126 | echo "\n"; | 126 | echo "\n"; |
127 | } | 127 | } |
128 | } | 128 | } |
129 | } | 129 | } |
130 | echo '</pre>'; | 130 | echo '</pre>'; |
131 | $o = ob_get_contents(); | 131 | $o = ob_get_contents(); |
132 | ob_end_clean(); | 132 | ob_end_clean(); |
133 | return $o; | 133 | return $o; |
134 | } | 134 | } |
135 | ?> | 135 | ?> |
136 | 136 | ||
137 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | 137 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
138 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 138 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
139 | <html lang="en" xml:lang="en"> | 139 | <html lang="en" xml:lang="en"> |
140 | <head> | 140 | <head> |
141 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> | 141 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
142 | <meta name="description" content="htmLawed <?php echo hl_version();?> test page" /> | 142 | <meta name="description" content="htmLawed <?php echo hl_version();?> test page" /> |
143 | <style type="text/css"><!--/*--><![CDATA[/*><!--*/ | 143 | <style type="text/css"><!--/*--><![CDATA[/*><!--*/ |
144 | a, a.resizer{text-decoration:none;} | 144 | a, a.resizer{text-decoration:none;} |
145 | a:hover, a.resizer:hover{color:red;} | 145 | a:hover, a.resizer:hover{color:red;} |
146 | a.resizer{color:green; float:right;} | 146 | a.resizer{color:green; float:right;} |
147 | body{background-color:#efefef;} | 147 | body{background-color:#efefef;} |
148 | body, button, div, html, input, p{font-size:13px; font-family:'Lucida grande', Verdana, Arial, Helvetica, sans-serif;} | 148 | body, button, div, html, input, p{font-size:13px; font-family:'Lucida grande', Verdana, Arial, Helvetica, sans-serif;} |
149 | button, input{font-size: 85%;} | 149 | button, input{font-size: 85%;} |
150 | div.help{border-top: 1px dotted gray; margin-top: 15px; padding-top: 15px; color:#999999;} | 150 | div.help{border-top: 1px dotted gray; margin-top: 15px; padding-top: 15px; color:#999999;} |
151 | #inputC, #inputD, #inputF, #inputR, #outputD, #outputF, #outputR, #settingF, #diff{display:block;} | 151 | #inputC, #inputD, #inputF, #inputR, #outputD, #outputF, #outputR, #settingF, #diff{display:block;} |
152 | #inputC, #settingF{background-color:white; border:1px gray solid; padding:3px;} | 152 | #inputC, #settingF{background-color:white; border:1px gray solid; padding:3px;} |
153 | #inputC li{margin: 0; padding: 0;} | 153 | #inputC li{margin: 0; padding: 0;} |
154 | #inputC ul{margin: 0; padding: 0; margin-left: 14px;} | 154 | #inputC ul{margin: 0; padding: 0; margin-left: 14px;} |
155 | #inputC input{margin: 0; margin-left: 2px; margin-right: 2px; padding: 1px; vertical-align: middle;} | 155 | #inputC input{margin: 0; margin-left: 2px; margin-right: 2px; padding: 1px; vertical-align: middle;} |
156 | #inputD{overflow:auto; background-color:#ffff99; border:1px #cc9966 solid; padding:3px;} | 156 | #inputD{overflow:auto; background-color:#ffff99; border:1px #cc9966 solid; padding:3px;} |
157 | #inputR{overflow:auto; background-color:#ffffcc; border:1px #ffcc99 solid; padding:3px;} | 157 | #inputR{overflow:auto; background-color:#ffffcc; border:1px #ffcc99 solid; padding:3px;} |
158 | #inputC, #settingF, #inputD, #inputR, #outputD, #outputR, #diff, textarea{font-size:100%; font-family:'Bitstream vera sans mono', 'courier new', 'courier', monospace;} | 158 | #inputC, #settingF, #inputD, #inputR, #outputD, #outputR, #diff, textarea{font-size:100%; font-family:'Bitstream vera sans mono', 'courier new', 'courier', monospace;} |
159 | #outputD{overflow:auto; background-color: #99ffcc; border:1px #66cc99 solid; padding:3px;} | 159 | #outputD{overflow:auto; background-color: #99ffcc; border:1px #66cc99 solid; padding:3px;} |
160 | #diff{overflow:auto; background-color: white; border:1px #dcdcdc solid; padding:3px;} | 160 | #diff{overflow:auto; background-color: white; border:1px #dcdcdc solid; padding:3px;} |
161 | #outputR{overflow:auto; background-color: #ccffcc; border:1px #99cc99 solid; padding:3px;} | 161 | #outputR{overflow:auto; background-color: #ccffcc; border:1px #99cc99 solid; padding:3px;} |
162 | span.cmtcdata{color: orange;} | 162 | span.cmtcdata{color: orange;} |
163 | span.ctag{color:red;} | 163 | span.ctag{color:red;} |
164 | span.ent{border-bottom:1px dotted #999999;} | 164 | span.ent{border-bottom:1px dotted #999999;} |
165 | span.etag{color:purple;} | 165 | span.etag{color:purple;} |
166 | span.help{color:#999999;} | 166 | span.help{color:#999999;} |
167 | span.newline{color:#dcdcdc;} | 167 | span.newline{color:#dcdcdc;} |
168 | span.notice{color:green;} | 168 | span.notice{color:green;} |
169 | span.otag{color:blue;} | 169 | span.otag{color:blue;} |
170 | #topmost{margin:auto; width:98%;} | 170 | #topmost{margin:auto; width:98%;} |
171 | /*]]>*/--></style> | 171 | /*]]>*/--></style> |
172 | <script type="text/javascript"><!--//--><![CDATA[//><!-- | 172 | <script type="text/javascript"><!--//--><![CDATA[//><!-- |
173 | window.name = 'hlmain'; | 173 | window.name = 'hlmain'; |
174 | function hl(i){ | 174 | function hl(i){ |
175 | <?php if(!$_hilite){echo 'return;'; }?> | 175 | <?php if(!$_hilite){echo 'return;'; }?> |
176 | var e = document.getElementById(i); | 176 | var e = document.getElementById(i); |
177 | if(!e){return;} | 177 | if(!e){return;} |
178 | run(e, '</[a-z1-6]+>', 'ctag'); | 178 | run(e, '</[a-z1-6]+>', 'ctag'); |
179 | run(e, '<[a-z]+(?:[^>]*)/>', 'etag'); | 179 | run(e, '<[a-z]+(?:[^>]*)/>', 'etag'); |
180 | run(e, '<[a-z1-6]+(?:[^>]*)>', 'otag'); | 180 | run(e, '<[a-z1-6]+(?:[^>]*)>', 'otag'); |
181 | run(e, '&[#a-z0-9]+;', 'ent'); | 181 | run(e, '&[#a-z0-9]+;', 'ent'); |
182 | run(e, '<!(?:(?:--(?:.|\n)*?--)|(?:\\[CDATA\\[(?:.|\n)*?\\]\\]))>', 'cmtcdata'); | 182 | run(e, '<!(?:(?:--(?:.|\n)*?--)|(?:\\[CDATA\\[(?:.|\n)*?\\]\\]))>', 'cmtcdata'); |
183 | } | 183 | } |
184 | function sndProc(){ | 184 | function sndProc(){ |
185 | var f = document.getElementById('testform'); | 185 | var f = document.getElementById('testform'); |
186 | if(!f){return;} | 186 | if(!f){return;} |
187 | var e = document.createElement('input'); | 187 | var e = document.createElement('input'); |
188 | e.type = 'hidden'; | 188 | e.type = 'hidden'; |
189 | e.name = '<?php echo htmlspecialchars($_sid); ?>'; | 189 | e.name = '<?php echo htmlspecialchars($_sid); ?>'; |
190 | e.id = '<?php echo htmlspecialchars($_sid); ?>'; | 190 | e.id = '<?php echo htmlspecialchars($_sid); ?>'; |
191 | e.value = readCookie('<?php echo htmlspecialchars($_sid); ?>'); | 191 | e.value = readCookie('<?php echo htmlspecialchars($_sid); ?>'); |
192 | f.appendChild(e); | 192 | f.appendChild(e); |
193 | f.submit(); | 193 | f.submit(); |
194 | } | 194 | } |
195 | function readCookie(n){ | 195 | function readCookie(n){ |
196 | var ne = n + '='; | 196 | var ne = n + '='; |
197 | var ca = document.cookie.split(';'); | 197 | var ca = document.cookie.split(';'); |
198 | for(var i=0;i < ca.length;i++){ | 198 | for(var i=0;i < ca.length;i++){ |
199 | var c = ca[i]; | 199 | var c = ca[i]; |
200 | while(c.charAt(0)==' '){ | 200 | while(c.charAt(0)==' '){ |
201 | c = c.substring(1,c.length); | 201 | c = c.substring(1,c.length); |
202 | } | 202 | } |
203 | if(c.indexOf(ne) == 0){ | 203 | if(c.indexOf(ne) == 0){ |
204 | return c.substring(ne.length,c.length); | 204 | return c.substring(ne.length,c.length); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | return null; | 207 | return null; |
208 | } | 208 | } |
209 | function run(e, q, c){ | 209 | function run(e, q, c){ |
210 | var q = new RegExp(q); | 210 | var q = new RegExp(q); |
211 | if(e.firstChild == null){ | 211 | if(e.firstChild == null){ |
212 | var m = q.exec(e.data); | 212 | var m = q.exec(e.data); |
213 | if(m){ | 213 | if(m){ |
214 | var v = m[0]; | 214 | var v = m[0]; |
215 | var k2 = e.splitText(m.index); | 215 | var k2 = e.splitText(m.index); |
216 | var k3 = k2.splitText(v.length); | 216 | var k3 = k2.splitText(v.length); |
217 | var s = e.ownerDocument.createElement('span'); | 217 | var s = e.ownerDocument.createElement('span'); |
218 | e.parentNode.replaceChild(s, k2); | 218 | e.parentNode.replaceChild(s, k2); |
219 | s.className = c; s.appendChild(k2); | 219 | s.className = c; s.appendChild(k2); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | for(var k = e.firstChild; k != null; k = k.nextSibling){ | 222 | for(var k = e.firstChild; k != null; k = k.nextSibling){ |
223 | if(k.nodeType == 3){ | 223 | if(k.nodeType == 3){ |
224 | var m = q.exec(k.data); | 224 | var m = q.exec(k.data); |
225 | if(m){ | 225 | if(m){ |
226 | var v = m[0]; | 226 | var v = m[0]; |
227 | var k2 = k.splitText(m.index); | 227 | var k2 = k.splitText(m.index); |
228 | var k3 = k2.splitText(v.length); | 228 | var k3 = k2.splitText(v.length); |
229 | var s = k.ownerDocument.createElement('span'); | 229 | var s = k.ownerDocument.createElement('span'); |
230 | k.parentNode.replaceChild(s, k2); | 230 | k.parentNode.replaceChild(s, k2); |
231 | s.className = c; s.appendChild(k2); | 231 | s.className = c; s.appendChild(k2); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | else if(c == 'ent' && k.nodeType == 1){ | 234 | else if(c == 'ent' && k.nodeType == 1){ |
235 | var d = k.firstChild; | 235 | var d = k.firstChild; |
236 | if(d){ | 236 | if(d){ |
237 | var m = q.exec(d.data); | 237 | var m = q.exec(d.data); |
238 | if(m){ | 238 | if(m){ |
239 | var v = m[0]; | 239 | var v = m[0]; |
240 | var d2 = d.splitText(m.index); | 240 | var d2 = d.splitText(m.index); |
241 | var d3 = d2.splitText(v.length); | 241 | var d3 = d2.splitText(v.length); |
242 | var s = d.ownerDocument.createElement('span'); | 242 | var s = d.ownerDocument.createElement('span'); |
243 | d.parentNode.replaceChild(s, d2); | 243 | d.parentNode.replaceChild(s, d2); |
244 | s.className = c; s.appendChild(d2); | 244 | s.className = c; s.appendChild(d2); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | } | 248 | } |
249 | } | 249 | } |
250 | function toggle(i){ | 250 | function toggle(i){ |
251 | var e = document.getElementById(i); | 251 | var e = document.getElementById(i); |
252 | if(!e){return;} | 252 | if(!e){return;} |
253 | if(e.style){ | 253 | if(e.style){ |
254 | var a = e.style.display; | 254 | var a = e.style.display; |
255 | if(a == 'block'){e.style.display = 'none'; return;} | 255 | if(a == 'block'){e.style.display = 'none'; return;} |
256 | if(a == 'none'){e.style.display = 'block';} | 256 | if(a == 'none'){e.style.display = 'block';} |
257 | else{e.style.display = 'none';} | 257 | else{e.style.display = 'none';} |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | var a = e.visibility; | 260 | var a = e.visibility; |
261 | if(a == 'hidden'){e.visibility = 'show'; return;} | 261 | if(a == 'hidden'){e.visibility = 'show'; return;} |
262 | if(a == 'show'){e.visibility = 'hidden';} | 262 | if(a == 'show'){e.visibility = 'hidden';} |
263 | } | 263 | } |
264 | function sndProc2(){ | 264 | function sndProc2(){ |
265 | var i = document.getElementById('text2'); | 265 | var i = document.getElementById('text2'); |
266 | if(!i){return;} | 266 | if(!i){return;} |
267 | i = i.value; | 267 | i = i.value; |
268 | var w = window.open('htmLawedTest.php?pre=1', 'hlposthtm'); | 268 | var w = window.open('htmLawedTest.php?pre=1', 'hlposthtm'); |
269 | var f = document.createElement('form'); | 269 | var f = document.createElement('form'); |
270 | f.enctype = 'application/x-www-form-urlencoded'; | 270 | f.enctype = 'application/x-www-form-urlencoded'; |
271 | f.method = 'post'; | 271 | f.method = 'post'; |
272 | f.acceptCharset = '<?php echo htmlspecialchars($_POST['enc']); ?>'; | 272 | f.acceptCharset = '<?php echo htmlspecialchars($_POST['enc']); ?>'; |
273 | if(f.style){f.style.display = 'none';} | 273 | if(f.style){f.style.display = 'none';} |
274 | else{f.visibility = 'hidden';} | 274 | else{f.visibility = 'hidden';} |
275 | f.innerHTML = '<p style="display:none;"><input style="display:none;" type="hidden" name="token" id="token" value="<?php echo $token; ?>" /><input style="display:none;" type="hidden" name="<?php echo htmlspecialchars($_sid); ?>" id="<?php echo htmlspecialchars($_sid); ?>" value="' + readCookie('<?php echo htmlspecialchars($_sid); ?>') + '" /></p>'; | 275 | f.innerHTML = '<p style="display:none;"><input style="display:none;" type="hidden" name="token" id="token" value="<?php echo $token; ?>" /><input style="display:none;" type="hidden" name="<?php echo htmlspecialchars($_sid); ?>" id="<?php echo htmlspecialchars($_sid); ?>" value="' + readCookie('<?php echo htmlspecialchars($_sid); ?>') + '" /></p>'; |
276 | f.action = 'htmLawedTest.php?pre=1'; | 276 | f.action = 'htmLawedTest.php?pre=1'; |
277 | f.target = 'hlposthtm'; | 277 | f.target = 'hlposthtm'; |
278 | f.method = 'post'; | 278 | f.method = 'post'; |
279 | var t = document.createElement('textarea'); | 279 | var t = document.createElement('textarea'); |
280 | t.name = 'outputH'; | 280 | t.name = 'outputH'; |
281 | t.value = i; | 281 | t.value = i; |
282 | f.appendChild(t); | 282 | f.appendChild(t); |
283 | var b = document.getElementsByTagName('body')[0]; | 283 | var b = document.getElementsByTagName('body')[0]; |
284 | b.appendChild(f); | 284 | b.appendChild(f); |
285 | f.submit(); | 285 | f.submit(); |
286 | w.focus; | 286 | w.focus; |
287 | } | 287 | } |
288 | function sndUnproc(){ | 288 | function sndUnproc(){ |
289 | var i = document.getElementById('text'); | 289 | var i = document.getElementById('text'); |
290 | if(!i){return;} | 290 | if(!i){return;} |
291 | i = i.value; | 291 | i = i.value; |
292 | var w = window.open('htmLawedTest.php?pre=1', 'hlprehtm'); | 292 | var w = window.open('htmLawedTest.php?pre=1', 'hlprehtm'); |
293 | var f = document.createElement('form'); | 293 | var f = document.createElement('form'); |
294 | f.enctype = 'application/x-www-form-urlencoded'; | 294 | f.enctype = 'application/x-www-form-urlencoded'; |
295 | f.method = 'post'; | 295 | f.method = 'post'; |
296 | f.acceptCharset = '<?php echo htmlspecialchars($_POST['enc']); ?>'; | 296 | f.acceptCharset = '<?php echo htmlspecialchars($_POST['enc']); ?>'; |
297 | if(f.style){f.style.display = 'none';} | 297 | if(f.style){f.style.display = 'none';} |
298 | else{f.visibility = 'hidden';} | 298 | else{f.visibility = 'hidden';} |
299 | f.innerHTML = '<p style="display:none;"><input style="display:none;" type="hidden" name="token" id="token" value="<?php echo $token; ?>" /><input style="display:none;" type="hidden" name="<?php echo htmlspecialchars($_sid); ?>" id="<?php echo htmlspecialchars($_sid); ?>" value="' + readCookie('<?php echo htmlspecialchars($_sid); ?>') + '" /></p>'; | 299 | f.innerHTML = '<p style="display:none;"><input style="display:none;" type="hidden" name="token" id="token" value="<?php echo $token; ?>" /><input style="display:none;" type="hidden" name="<?php echo htmlspecialchars($_sid); ?>" id="<?php echo htmlspecialchars($_sid); ?>" value="' + readCookie('<?php echo htmlspecialchars($_sid); ?>') + '" /></p>'; |
300 | f.action = 'htmLawedTest.php?pre=1'; | 300 | f.action = 'htmLawedTest.php?pre=1'; |
301 | f.target = 'hlprehtm'; | 301 | f.target = 'hlprehtm'; |
302 | f.method = 'post'; | 302 | f.method = 'post'; |
303 | var t = document.createElement('textarea'); | 303 | var t = document.createElement('textarea'); |
304 | t.name = 'inputH'; | 304 | t.name = 'inputH'; |
305 | t.value = i; | 305 | t.value = i; |
306 | f.appendChild(t); | 306 | f.appendChild(t); |
307 | var b = document.getElementsByTagName('body')[0]; | 307 | var b = document.getElementsByTagName('body')[0]; |
308 | b.appendChild(f); | 308 | b.appendChild(f); |
309 | f.submit(); | 309 | f.submit(); |
310 | w.focus; | 310 | w.focus; |
311 | } | 311 | } |
312 | function sndValidn(id, type){ | 312 | function sndValidn(id, type){ |
313 | var i = document.getElementById(id); | 313 | var i = document.getElementById(id); |
314 | if(!i){return;} | 314 | if(!i){return;} |
315 | i = i.value; | 315 | i = i.value; |
316 | var w = window.open('http://validator.w3.org/check', 'validate'+id+type); | 316 | var w = window.open('http://validator.w3.org/check', 'validate'+id+type); |
317 | var f = document.createElement('form'); | 317 | var f = document.createElement('form'); |
318 | f.enctype = 'application/x-www-form-urlencoded'; | 318 | f.enctype = 'application/x-www-form-urlencoded'; |
319 | f.method = 'post'; | 319 | f.method = 'post'; |
320 | f.acceptCharset = '<?php echo htmlspecialchars($_POST['enc']); ?>'; | 320 | f.acceptCharset = '<?php echo htmlspecialchars($_POST['enc']); ?>'; |
321 | if(f.style){f.style.display = 'none';} | 321 | if(f.style){f.style.display = 'none';} |
322 | else{f.visibility = 'hidden';} | 322 | else{f.visibility = 'hidden';} |
323 | f.innerHTML = '<p style="display:none;"><input style="display:none;" type="hidden" name="prefill" id="prefill" value="1" /><input style="display:none;" type="hidden" name="prefill_doctype" id="prefill_doctype" value="'+ type+ '" /><input style="display:none;" type="hidden" name="group" id="group" value="1" /><input type="hidden" name="ss" id="ss" value="1" /></p>'; | 323 | f.innerHTML = '<p style="display:none;"><input style="display:none;" type="hidden" name="prefill" id="prefill" value="1" /><input style="display:none;" type="hidden" name="prefill_doctype" id="prefill_doctype" value="'+ type+ '" /><input style="display:none;" type="hidden" name="group" id="group" value="1" /><input type="hidden" name="ss" id="ss" value="1" /></p>'; |
324 | f.action = 'http://validator.w3.org/check'; | 324 | f.action = 'http://validator.w3.org/check'; |
325 | f.target = 'validate'+id+type; | 325 | f.target = 'validate'+id+type; |
326 | var t = document.createElement('textarea'); | 326 | var t = document.createElement('textarea'); |
327 | t.name = 'fragment'; | 327 | t.name = 'fragment'; |
328 | t.value = i; | 328 | t.value = i; |
329 | f.appendChild(t); | 329 | f.appendChild(t); |
330 | var b = document.getElementsByTagName('body')[0]; | 330 | var b = document.getElementsByTagName('body')[0]; |
331 | b.appendChild(f); | 331 | b.appendChild(f); |
332 | f.submit(); | 332 | f.submit(); |
333 | w.focus; | 333 | w.focus; |
334 | } | 334 | } |
335 | tRs = { | 335 | tRs = { |
336 | formEl: null, | 336 | formEl: null, |
337 | resizeClass: 'textarea', | 337 | resizeClass: 'textarea', |
338 | adEv: function(t,ev,fn){ | 338 | adEv: function(t,ev,fn){ |
339 | if(typeof document.addEventListener != 'undefined'){ | 339 | if(typeof document.addEventListener != 'undefined'){ |
340 | t.addEventListener(ev,fn,false); | 340 | t.addEventListener(ev,fn,false); |
341 | }else{ | 341 | }else{ |
342 | t.attachEvent('on' + ev, fn); | 342 | t.attachEvent('on' + ev, fn); |
343 | } | 343 | } |
344 | }, | 344 | }, |
345 | rmEv: function(t,ev,fn){ | 345 | rmEv: function(t,ev,fn){ |
346 | if(typeof document.removeEventListener != 'undefined'){ | 346 | if(typeof document.removeEventListener != 'undefined'){ |
347 | t.removeEventListener(ev,fn,false); | 347 | t.removeEventListener(ev,fn,false); |
348 | }else | 348 | }else |
349 | { | 349 | { |
350 | t.detachEvent('on' + ev, fn); | 350 | t.detachEvent('on' + ev, fn); |
351 | } | 351 | } |
352 | }, | 352 | }, |
353 | adBtn: function(){ | 353 | adBtn: function(){ |
354 | var textareas = document.getElementsByTagName('textarea'); | 354 | var textareas = document.getElementsByTagName('textarea'); |
355 | for(var i = 0; i < textareas.length; i++){ | 355 | for(var i = 0; i < textareas.length; i++){ |
356 | var txtclass=textareas[i].className; | 356 | var txtclass=textareas[i].className; |
357 | if(txtclass.substring(0,tRs.resizeClass.length)==tRs.resizeClass || | 357 | if(txtclass.substring(0,tRs.resizeClass.length)==tRs.resizeClass || |
358 | txtclass.substring(txtclass.length -tRs.resizeClass.length)==tRs.resizeClass){ | 358 | txtclass.substring(txtclass.length -tRs.resizeClass.length)==tRs.resizeClass){ |
359 | var a = document.createElement('a'); | 359 | var a = document.createElement('a'); |
360 | a.appendChild(document.createTextNode("\u2195")); | 360 | a.appendChild(document.createTextNode("\u2195")); |
361 | a.style.cursor = 'n-resize'; | 361 | a.style.cursor = 'n-resize'; |
362 | a.className= 'resizer'; | 362 | a.className= 'resizer'; |
363 | a.title = 'click-drag to resize textarea' | 363 | a.title = 'click-drag to resize textarea' |
364 | tRs.adEv(a, 'mousedown', tRs.initResize); | 364 | tRs.adEv(a, 'mousedown', tRs.initResize); |
365 | textareas[i].parentNode.appendChild(a); | 365 | textareas[i].parentNode.appendChild(a); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | }, | 368 | }, |
369 | initResize: function(event){ | 369 | initResize: function(event){ |
370 | if(typeof event == 'undefined'){ | 370 | if(typeof event == 'undefined'){ |
371 | event = window.event; | 371 | event = window.event; |
372 | } | 372 | } |
373 | if(event.srcElement){ | 373 | if(event.srcElement){ |
374 | var target = event.srcElement.previousSibling; | 374 | var target = event.srcElement.previousSibling; |
375 | }else{ | 375 | }else{ |
376 | var target = event.target.previousSibling; | 376 | var target = event.target.previousSibling; |
377 | } | 377 | } |
378 | if(target.nodeName.toLowerCase() == 'textarea' || (target.nodeName.toLowerCase() == 'input' && target.type == 'text')){ | 378 | if(target.nodeName.toLowerCase() == 'textarea' || (target.nodeName.toLowerCase() == 'input' && target.type == 'text')){ |
379 | tRs.formEl = target; | 379 | tRs.formEl = target; |
380 | tRs.formEl.startHeight = tRs.formEl.clientHeight; | 380 | tRs.formEl.startHeight = tRs.formEl.clientHeight; |
381 | tRs.formEl.startY = event.clientY; | 381 | tRs.formEl.startY = event.clientY; |
382 | tRs.adEv(document, 'mousemove', tRs.resize); | 382 | tRs.adEv(document, 'mousemove', tRs.resize); |
383 | tRs.adEv(document, 'mouseup', tRs.stopResize); | 383 | tRs.adEv(document, 'mouseup', tRs.stopResize); |
384 | tRs.formEl.parentNode.style.cursor = 'n-resize'; | 384 | tRs.formEl.parentNode.style.cursor = 'n-resize'; |
385 | tRs.formEl.style.cursor = 'n-resize'; | 385 | tRs.formEl.style.cursor = 'n-resize'; |
386 | try{ | 386 | try{ |
387 | event.preventDefault(); | 387 | event.preventDefault(); |
388 | }catch(e){ | 388 | }catch(e){ |
389 | } | 389 | } |
390 | } | 390 | } |
391 | }, | 391 | }, |
392 | resize: function(event){ | 392 | resize: function(event){ |
393 | if(typeof event == 'undefined'){ | 393 | if(typeof event == 'undefined'){ |
394 | event = window.event; | 394 | event = window.event; |
395 | } | 395 | } |
396 | if(tRs.formEl.nodeName.toLowerCase() == 'textarea'){ | 396 | if(tRs.formEl.nodeName.toLowerCase() == 'textarea'){ |
397 | tRs.formEl.style.height = event.clientY - tRs.formEl.startY + tRs.formEl.startHeight + 'px'; | 397 | tRs.formEl.style.height = event.clientY - tRs.formEl.startY + tRs.formEl.startHeight + 'px'; |
398 | } | 398 | } |
399 | }, | 399 | }, |
400 | stopResize: function(event){ | 400 | stopResize: function(event){ |
401 | tRs.rmEv(document, 'mousedown', tRs.initResize); | 401 | tRs.rmEv(document, 'mousedown', tRs.initResize); |
402 | tRs.rmEv(document, 'mousemove', tRs.resize); | 402 | tRs.rmEv(document, 'mousemove', tRs.resize); |
403 | tRs.formEl.style.cursor = 'text'; | 403 | tRs.formEl.style.cursor = 'text'; |
404 | tRs.formEl.parentNode.style.cursor = 'auto'; | 404 | tRs.formEl.parentNode.style.cursor = 'auto'; |
405 | return false; | 405 | return false; |
406 | } | 406 | } |
407 | }; | 407 | }; |
408 | tRs.adEv(window, 'load', tRs.adBtn); | 408 | tRs.adEv(window, 'load', tRs.adBtn); |
409 | // Diff Match and Patch javascript code by Neil Fraser; Apache license 2.0; http://code.google.com/p/google-diff-match-patch/ | 409 | // Diff Match and Patch javascript code by Neil Fraser; Apache license 2.0; http://code.google.com/p/google-diff-match-patch/ |
410 | (function(){function diff_match_patch(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=0.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=0.5;this.Patch_Margin=4;this.Match_MaxBits=32} | 410 | (function(){function diff_match_patch(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=0.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=0.5;this.Patch_Margin=4;this.Match_MaxBits=32} |
411 | diff_match_patch.prototype.diff_main=function(a,b,c,d){"undefined"==typeof d&&(d=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[[0,a]]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b),c=a.substring(0,f),a=a.substring(f),b=b.substring(f),f=this.diff_commonSuffix(a,b),g=a.substring(a.length-f),a=a.substring(0,a.length-f),b=b.substring(0,b.length-f),a=this.diff_compute_(a, | 411 | diff_match_patch.prototype.diff_main=function(a,b,c,d){"undefined"==typeof d&&(d=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[[0,a]]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b),c=a.substring(0,f),a=a.substring(f),b=b.substring(f),f=this.diff_commonSuffix(a,b),g=a.substring(a.length-f),a=a.substring(0,a.length-f),b=b.substring(0,b.length-f),a=this.diff_compute_(a, |
412 | b,e,d);c&&a.unshift([0,c]);g&&a.push([0,g]);this.diff_cleanupMerge(a);return a}; | 412 | b,e,d);c&&a.unshift([0,c]);g&&a.push([0,g]);this.diff_cleanupMerge(a);return a}; |
413 | diff_match_patch.prototype.diff_compute_=function(a,b,c,d){if(!a)return[[1,b]];if(!b)return[[-1,a]];var e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=e.indexOf(f);if(-1!=g)return c=[[1,e.substring(0,g)],[0,f],[1,e.substring(g+f.length)]],a.length>b.length&&(c[0][0]=c[2][0]=-1),c;if(1==f.length)return[[-1,a],[1,b]];return(e=this.diff_halfMatch_(a,b))?(f=e[0],a=e[1],g=e[2],b=e[3],e=e[4],f=this.diff_main(f,g,c,d),c=this.diff_main(a,b,c,d),f.concat([[0,e]],c)):c&&100<a.length&&100<b.length?this.diff_lineMode_(a, | 413 | diff_match_patch.prototype.diff_compute_=function(a,b,c,d){if(!a)return[[1,b]];if(!b)return[[-1,a]];var e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=e.indexOf(f);if(-1!=g)return c=[[1,e.substring(0,g)],[0,f],[1,e.substring(g+f.length)]],a.length>b.length&&(c[0][0]=c[2][0]=-1),c;if(1==f.length)return[[-1,a],[1,b]];return(e=this.diff_halfMatch_(a,b))?(f=e[0],a=e[1],g=e[2],b=e[3],e=e[4],f=this.diff_main(f,g,c,d),c=this.diff_main(a,b,c,d),f.concat([[0,e]],c)):c&&100<a.length&&100<b.length?this.diff_lineMode_(a, |
414 | b,d):this.diff_bisect_(a,b,d)}; | 414 | b,d):this.diff_bisect_(a,b,d)}; |
415 | diff_match_patch.prototype.diff_lineMode_=function(a,b,c){var d=this.diff_linesToChars_(a,b),a=d.chars1,b=d.chars2,d=d.lineArray,a=this.diff_main(a,b,!1,c);this.diff_charsToLines_(a,d);this.diff_cleanupSemantic(a);a.push([0,""]);for(var e=d=b=0,f="",g="";b<a.length;){switch(a[b][0]){case 1:e++;g+=a[b][1];break;case -1:d++;f+=a[b][1];break;case 0:if(1<=d&&1<=e){a.splice(b-d-e,d+e);b=b-d-e;d=this.diff_main(f,g,!1,c);for(e=d.length-1;0<=e;e--)a.splice(b,0,d[e]);b+=d.length}d=e=0;g=f=""}b++}a.pop();return a}; | 415 | diff_match_patch.prototype.diff_lineMode_=function(a,b,c){var d=this.diff_linesToChars_(a,b),a=d.chars1,b=d.chars2,d=d.lineArray,a=this.diff_main(a,b,!1,c);this.diff_charsToLines_(a,d);this.diff_cleanupSemantic(a);a.push([0,""]);for(var e=d=b=0,f="",g="";b<a.length;){switch(a[b][0]){case 1:e++;g+=a[b][1];break;case -1:d++;f+=a[b][1];break;case 0:if(1<=d&&1<=e){a.splice(b-d-e,d+e);b=b-d-e;d=this.diff_main(f,g,!1,c);for(e=d.length-1;0<=e;e--)a.splice(b,0,d[e]);b+=d.length}d=e=0;g=f=""}b++}a.pop();return a}; |
416 | diff_match_patch.prototype.diff_bisect_=function(a,b,c){for(var d=a.length,e=b.length,f=Math.ceil((d+e)/2),g=f,h=2*f,j=Array(h),i=Array(h),k=0;k<h;k++)j[k]=-1,i[k]=-1;j[g+1]=0;i[g+1]=0;for(var k=d-e,p=0!=k%2,q=0,s=0,o=0,v=0,u=0;u<f&&!((new Date).getTime()>c);u++){for(var n=-u+q;n<=u-s;n+=2){var l=g+n,m;m=n==-u||n!=u&&j[l-1]<j[l+1]?j[l+1]:j[l-1]+1;for(var r=m-n;m<d&&r<e&&a.charAt(m)==b.charAt(r);)m++,r++;j[l]=m;if(m>d)s+=2;else if(r>e)q+=2;else if(p&&(l=g+k-n,0<=l&&l<h&&-1!=i[l])){var t=d-i[l];if(m>= | 416 | diff_match_patch.prototype.diff_bisect_=function(a,b,c){for(var d=a.length,e=b.length,f=Math.ceil((d+e)/2),g=f,h=2*f,j=Array(h),i=Array(h),k=0;k<h;k++)j[k]=-1,i[k]=-1;j[g+1]=0;i[g+1]=0;for(var k=d-e,p=0!=k%2,q=0,s=0,o=0,v=0,u=0;u<f&&!((new Date).getTime()>c);u++){for(var n=-u+q;n<=u-s;n+=2){var l=g+n,m;m=n==-u||n!=u&&j[l-1]<j[l+1]?j[l+1]:j[l-1]+1;for(var r=m-n;m<d&&r<e&&a.charAt(m)==b.charAt(r);)m++,r++;j[l]=m;if(m>d)s+=2;else if(r>e)q+=2;else if(p&&(l=g+k-n,0<=l&&l<h&&-1!=i[l])){var t=d-i[l];if(m>= |
417 | t)return this.diff_bisectSplit_(a,b,m,r,c)}}for(n=-u+o;n<=u-v;n+=2){l=g+n;t=n==-u||n!=u&&i[l-1]<i[l+1]?i[l+1]:i[l-1]+1;for(m=t-n;t<d&&m<e&&a.charAt(d-t-1)==b.charAt(e-m-1);)t++,m++;i[l]=t;if(t>d)v+=2;else if(m>e)o+=2;else if(!p&&(l=g+k-n,0<=l&&l<h&&-1!=j[l]&&(m=j[l],r=g+m-l,t=d-t,m>=t)))return this.diff_bisectSplit_(a,b,m,r,c)}}return[[-1,a],[1,b]]}; | 417 | t)return this.diff_bisectSplit_(a,b,m,r,c)}}for(n=-u+o;n<=u-v;n+=2){l=g+n;t=n==-u||n!=u&&i[l-1]<i[l+1]?i[l+1]:i[l-1]+1;for(m=t-n;t<d&&m<e&&a.charAt(d-t-1)==b.charAt(e-m-1);)t++,m++;i[l]=t;if(t>d)v+=2;else if(m>e)o+=2;else if(!p&&(l=g+k-n,0<=l&&l<h&&-1!=j[l]&&(m=j[l],r=g+m-l,t=d-t,m>=t)))return this.diff_bisectSplit_(a,b,m,r,c)}}return[[-1,a],[1,b]]}; |
418 | diff_match_patch.prototype.diff_bisectSplit_=function(a,b,c,d,e){var f=a.substring(0,c),g=b.substring(0,d),a=a.substring(c),b=b.substring(d),f=this.diff_main(f,g,!1,e),e=this.diff_main(a,b,!1,e);return f.concat(e)}; | 418 | diff_match_patch.prototype.diff_bisectSplit_=function(a,b,c,d,e){var f=a.substring(0,c),g=b.substring(0,d),a=a.substring(c),b=b.substring(d),f=this.diff_main(f,g,!1,e),e=this.diff_main(a,b,!1,e);return f.concat(e)}; |
419 | diff_match_patch.prototype.diff_linesToChars_=function(a,b){function c(a){for(var b="",c=0,f=-1,g=d.length;f<a.length-1;){f=a.indexOf("\n",c);-1==f&&(f=a.length-1);var q=a.substring(c,f+1),c=f+1;(e.hasOwnProperty?e.hasOwnProperty(q):void 0!==e[q])?b+=String.fromCharCode(e[q]):(b+=String.fromCharCode(g),e[q]=g,d[g++]=q)}return b}var d=[],e={};d[0]="";var f=c(a),g=c(b);return{chars1:f,chars2:g,lineArray:d}}; | 419 | diff_match_patch.prototype.diff_linesToChars_=function(a,b){function c(a){for(var b="",c=0,f=-1,g=d.length;f<a.length-1;){f=a.indexOf("\n",c);-1==f&&(f=a.length-1);var q=a.substring(c,f+1),c=f+1;(e.hasOwnProperty?e.hasOwnProperty(q):void 0!==e[q])?b+=String.fromCharCode(e[q]):(b+=String.fromCharCode(g),e[q]=g,d[g++]=q)}return b}var d=[],e={};d[0]="";var f=c(a),g=c(b);return{chars1:f,chars2:g,lineArray:d}}; |
420 | diff_match_patch.prototype.diff_charsToLines_=function(a,b){for(var c=0;c<a.length;c++){for(var d=a[c][1],e=[],f=0;f<d.length;f++)e[f]=b[d.charCodeAt(f)];a[c][1]=e.join("")}};diff_match_patch.prototype.diff_commonPrefix=function(a,b){if(!a||!b||a.charAt(0)!=b.charAt(0))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;c<e;)a.substring(f,e)==b.substring(f,e)?f=c=e:d=e,e=Math.floor((d-c)/2+c);return e}; | 420 | diff_match_patch.prototype.diff_charsToLines_=function(a,b){for(var c=0;c<a.length;c++){for(var d=a[c][1],e=[],f=0;f<d.length;f++)e[f]=b[d.charCodeAt(f)];a[c][1]=e.join("")}};diff_match_patch.prototype.diff_commonPrefix=function(a,b){if(!a||!b||a.charAt(0)!=b.charAt(0))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;c<e;)a.substring(f,e)==b.substring(f,e)?f=c=e:d=e,e=Math.floor((d-c)/2+c);return e}; |
421 | diff_match_patch.prototype.diff_commonSuffix=function(a,b){if(!a||!b||a.charAt(a.length-1)!=b.charAt(b.length-1))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;c<e;)a.substring(a.length-e,a.length-f)==b.substring(b.length-e,b.length-f)?f=c=e:d=e,e=Math.floor((d-c)/2+c);return e}; | 421 | diff_match_patch.prototype.diff_commonSuffix=function(a,b){if(!a||!b||a.charAt(a.length-1)!=b.charAt(b.length-1))return 0;for(var c=0,d=Math.min(a.length,b.length),e=d,f=0;c<e;)a.substring(a.length-e,a.length-f)==b.substring(b.length-e,b.length-f)?f=c=e:d=e,e=Math.floor((d-c)/2+c);return e}; |
422 | diff_match_patch.prototype.diff_commonOverlap_=function(a,b){var c=a.length,d=b.length;if(0==c||0==d)return 0;c>d?a=a.substring(c-d):c<d&&(b=b.substring(0,c));c=Math.min(c,d);if(a==b)return c;for(var d=0,e=1;;){var f=a.substring(c-e),f=b.indexOf(f);if(-1==f)return d;e+=f;if(0==f||a.substring(c-e)==b.substring(0,e))d=e,e++}}; | 422 | diff_match_patch.prototype.diff_commonOverlap_=function(a,b){var c=a.length,d=b.length;if(0==c||0==d)return 0;c>d?a=a.substring(c-d):c<d&&(b=b.substring(0,c));c=Math.min(c,d);if(a==b)return c;for(var d=0,e=1;;){var f=a.substring(c-e),f=b.indexOf(f);if(-1==f)return d;e+=f;if(0==f||a.substring(c-e)==b.substring(0,e))d=e,e++}}; |
423 | diff_match_patch.prototype.diff_halfMatch_=function(a,b){function c(a,b,c){for(var d=a.substring(c,c+Math.floor(a.length/4)),e=-1,g="",h,j,n,l;-1!=(e=b.indexOf(d,e+1));){var m=f.diff_commonPrefix(a.substring(c),b.substring(e)),r=f.diff_commonSuffix(a.substring(0,c),b.substring(0,e));g.length<r+m&&(g=b.substring(e-r,e)+b.substring(e,e+m),h=a.substring(0,c-r),j=a.substring(c+m),n=b.substring(0,e-r),l=b.substring(e+m))}return 2*g.length>=a.length?[h,j,n,l,g]:null}if(0>=this.Diff_Timeout)return null; | 423 | diff_match_patch.prototype.diff_halfMatch_=function(a,b){function c(a,b,c){for(var d=a.substring(c,c+Math.floor(a.length/4)),e=-1,g="",h,j,n,l;-1!=(e=b.indexOf(d,e+1));){var m=f.diff_commonPrefix(a.substring(c),b.substring(e)),r=f.diff_commonSuffix(a.substring(0,c),b.substring(0,e));g.length<r+m&&(g=b.substring(e-r,e)+b.substring(e,e+m),h=a.substring(0,c-r),j=a.substring(c+m),n=b.substring(0,e-r),l=b.substring(e+m))}return 2*g.length>=a.length?[h,j,n,l,g]:null}if(0>=this.Diff_Timeout)return null; |
424 | var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(4>d.length||2*e.length<d.length)return null;var f=this,g=c(d,e,Math.ceil(d.length/4)),d=c(d,e,Math.ceil(d.length/2)),h;if(!g&&!d)return null;h=d?g?g[4].length>d[4].length?g:d:d:g;var j;a.length>b.length?(g=h[0],d=h[1],e=h[2],j=h[3]):(e=h[0],j=h[1],g=h[2],d=h[3]);h=h[4];return[g,d,e,j,h]}; | 424 | var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(4>d.length||2*e.length<d.length)return null;var f=this,g=c(d,e,Math.ceil(d.length/4)),d=c(d,e,Math.ceil(d.length/2)),h;if(!g&&!d)return null;h=d?g?g[4].length>d[4].length?g:d:d:g;var j;a.length>b.length?(g=h[0],d=h[1],e=h[2],j=h[3]):(e=h[0],j=h[1],g=h[2],d=h[3]);h=h[4];return[g,d,e,j,h]}; |
425 | diff_match_patch.prototype.diff_cleanupSemantic=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=0,h=0,j=0,i=0;f<a.length;)0==a[f][0]?(c[d++]=f,g=j,h=i,i=j=0,e=a[f][1]):(1==a[f][0]?j+=a[f][1].length:i+=a[f][1].length,e&&e.length<=Math.max(g,h)&&e.length<=Math.max(j,i)&&(a.splice(c[d-1],0,[-1,e]),a[c[d-1]+1][0]=1,d--,d--,f=0<d?c[d-1]:-1,i=j=h=g=0,e=null,b=!0)),f++;b&&this.diff_cleanupMerge(a);this.diff_cleanupSemanticLossless(a);for(f=1;f<a.length;){if(-1==a[f-1][0]&&1==a[f][0]){b=a[f-1][1];c=a[f][1]; | 425 | diff_match_patch.prototype.diff_cleanupSemantic=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=0,h=0,j=0,i=0;f<a.length;)0==a[f][0]?(c[d++]=f,g=j,h=i,i=j=0,e=a[f][1]):(1==a[f][0]?j+=a[f][1].length:i+=a[f][1].length,e&&e.length<=Math.max(g,h)&&e.length<=Math.max(j,i)&&(a.splice(c[d-1],0,[-1,e]),a[c[d-1]+1][0]=1,d--,d--,f=0<d?c[d-1]:-1,i=j=h=g=0,e=null,b=!0)),f++;b&&this.diff_cleanupMerge(a);this.diff_cleanupSemanticLossless(a);for(f=1;f<a.length;){if(-1==a[f-1][0]&&1==a[f][0]){b=a[f-1][1];c=a[f][1]; |
426 | d=this.diff_commonOverlap_(b,c);e=this.diff_commonOverlap_(c,b);if(d>=e){if(d>=b.length/2||d>=c.length/2)a.splice(f,0,[0,c.substring(0,d)]),a[f-1][1]=b.substring(0,b.length-d),a[f+1][1]=c.substring(d),f++}else if(e>=b.length/2||e>=c.length/2)a.splice(f,0,[0,b.substring(0,e)]),a[f-1][0]=1,a[f-1][1]=c.substring(0,c.length-e),a[f+1][0]=-1,a[f+1][1]=b.substring(e),f++;f++}f++}}; | 426 | d=this.diff_commonOverlap_(b,c);e=this.diff_commonOverlap_(c,b);if(d>=e){if(d>=b.length/2||d>=c.length/2)a.splice(f,0,[0,c.substring(0,d)]),a[f-1][1]=b.substring(0,b.length-d),a[f+1][1]=c.substring(d),f++}else if(e>=b.length/2||e>=c.length/2)a.splice(f,0,[0,b.substring(0,e)]),a[f-1][0]=1,a[f-1][1]=c.substring(0,c.length-e),a[f+1][0]=-1,a[f+1][1]=b.substring(e),f++;f++}f++}}; |
427 | diff_match_patch.prototype.diff_cleanupSemanticLossless=function(a){function b(a,b){if(!a||!b)return 6;var c=a.charAt(a.length-1),d=b.charAt(0),e=c.match(diff_match_patch.nonAlphaNumericRegex_),f=d.match(diff_match_patch.nonAlphaNumericRegex_),g=e&&c.match(diff_match_patch.whitespaceRegex_),h=f&&d.match(diff_match_patch.whitespaceRegex_),c=g&&c.match(diff_match_patch.linebreakRegex_),d=h&&d.match(diff_match_patch.linebreakRegex_),i=c&&a.match(diff_match_patch.blanklineEndRegex_),j=d&&b.match(diff_match_patch.blanklineStartRegex_); | 427 | diff_match_patch.prototype.diff_cleanupSemanticLossless=function(a){function b(a,b){if(!a||!b)return 6;var c=a.charAt(a.length-1),d=b.charAt(0),e=c.match(diff_match_patch.nonAlphaNumericRegex_),f=d.match(diff_match_patch.nonAlphaNumericRegex_),g=e&&c.match(diff_match_patch.whitespaceRegex_),h=f&&d.match(diff_match_patch.whitespaceRegex_),c=g&&c.match(diff_match_patch.linebreakRegex_),d=h&&d.match(diff_match_patch.linebreakRegex_),i=c&&a.match(diff_match_patch.blanklineEndRegex_),j=d&&b.match(diff_match_patch.blanklineStartRegex_); |
428 | return i||j?5:c||d?4:e&&!g&&h?3:g||h?2:e||f?1:0}for(var c=1;c<a.length-1;){if(0==a[c-1][0]&&0==a[c+1][0]){var d=a[c-1][1],e=a[c][1],f=a[c+1][1],g=this.diff_commonSuffix(d,e);if(g)var h=e.substring(e.length-g),d=d.substring(0,d.length-g),e=h+e.substring(0,e.length-g),f=h+f;for(var g=d,h=e,j=f,i=b(d,e)+b(e,f);e.charAt(0)===f.charAt(0);){var d=d+e.charAt(0),e=e.substring(1)+f.charAt(0),f=f.substring(1),k=b(d,e)+b(e,f);k>=i&&(i=k,g=d,h=e,j=f)}a[c-1][1]!=g&&(g?a[c-1][1]=g:(a.splice(c-1,1),c--),a[c][1]= | 428 | return i||j?5:c||d?4:e&&!g&&h?3:g||h?2:e||f?1:0}for(var c=1;c<a.length-1;){if(0==a[c-1][0]&&0==a[c+1][0]){var d=a[c-1][1],e=a[c][1],f=a[c+1][1],g=this.diff_commonSuffix(d,e);if(g)var h=e.substring(e.length-g),d=d.substring(0,d.length-g),e=h+e.substring(0,e.length-g),f=h+f;for(var g=d,h=e,j=f,i=b(d,e)+b(e,f);e.charAt(0)===f.charAt(0);){var d=d+e.charAt(0),e=e.substring(1)+f.charAt(0),f=f.substring(1),k=b(d,e)+b(e,f);k>=i&&(i=k,g=d,h=e,j=f)}a[c-1][1]!=g&&(g?a[c-1][1]=g:(a.splice(c-1,1),c--),a[c][1]= |
429 | h,j?a[c+1][1]=j:(a.splice(c+1,1),c--))}c++}};diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;diff_match_patch.whitespaceRegex_=/\s/;diff_match_patch.linebreakRegex_=/[\r\n]/;diff_match_patch.blanklineEndRegex_=/\n\r?\n$/;diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/; | 429 | h,j?a[c+1][1]=j:(a.splice(c+1,1),c--))}c++}};diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;diff_match_patch.whitespaceRegex_=/\s/;diff_match_patch.linebreakRegex_=/[\r\n]/;diff_match_patch.blanklineEndRegex_=/\n\r?\n$/;diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/; |
430 | diff_match_patch.prototype.diff_cleanupEfficiency=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=!1,h=!1,j=!1,i=!1;f<a.length;){if(0==a[f][0])a[f][1].length<this.Diff_EditCost&&(j||i)?(c[d++]=f,g=j,h=i,e=a[f][1]):(d=0,e=null),j=i=!1;else if(-1==a[f][0]?i=!0:j=!0,e&&(g&&h&&j&&i||e.length<this.Diff_EditCost/2&&3==g+h+j+i))a.splice(c[d-1],0,[-1,e]),a[c[d-1]+1][0]=1,d--,e=null,g&&h?(j=i=!0,d=0):(d--,f=0<d?c[d-1]:-1,j=i=!1),b=!0;f++}b&&this.diff_cleanupMerge(a)}; | 430 | diff_match_patch.prototype.diff_cleanupEfficiency=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=!1,h=!1,j=!1,i=!1;f<a.length;){if(0==a[f][0])a[f][1].length<this.Diff_EditCost&&(j||i)?(c[d++]=f,g=j,h=i,e=a[f][1]):(d=0,e=null),j=i=!1;else if(-1==a[f][0]?i=!0:j=!0,e&&(g&&h&&j&&i||e.length<this.Diff_EditCost/2&&3==g+h+j+i))a.splice(c[d-1],0,[-1,e]),a[c[d-1]+1][0]=1,d--,e=null,g&&h?(j=i=!0,d=0):(d--,f=0<d?c[d-1]:-1,j=i=!1),b=!0;f++}b&&this.diff_cleanupMerge(a)}; |
431 | diff_match_patch.prototype.diff_cleanupMerge=function(a){a.push([0,""]);for(var b=0,c=0,d=0,e="",f="",g;b<a.length;)switch(a[b][0]){case 1:d++;f+=a[b][1];b++;break;case -1:c++;e+=a[b][1];b++;break;case 0:1<c+d?(0!==c&&0!==d&&(g=this.diff_commonPrefix(f,e),0!==g&&(0<b-c-d&&0==a[b-c-d-1][0]?a[b-c-d-1][1]+=f.substring(0,g):(a.splice(0,0,[0,f.substring(0,g)]),b++),f=f.substring(g),e=e.substring(g)),g=this.diff_commonSuffix(f,e),0!==g&&(a[b][1]=f.substring(f.length-g)+a[b][1],f=f.substring(0,f.length- | 431 | diff_match_patch.prototype.diff_cleanupMerge=function(a){a.push([0,""]);for(var b=0,c=0,d=0,e="",f="",g;b<a.length;)switch(a[b][0]){case 1:d++;f+=a[b][1];b++;break;case -1:c++;e+=a[b][1];b++;break;case 0:1<c+d?(0!==c&&0!==d&&(g=this.diff_commonPrefix(f,e),0!==g&&(0<b-c-d&&0==a[b-c-d-1][0]?a[b-c-d-1][1]+=f.substring(0,g):(a.splice(0,0,[0,f.substring(0,g)]),b++),f=f.substring(g),e=e.substring(g)),g=this.diff_commonSuffix(f,e),0!==g&&(a[b][1]=f.substring(f.length-g)+a[b][1],f=f.substring(0,f.length- |
432 | g),e=e.substring(0,e.length-g))),0===c?a.splice(b-d,c+d,[1,f]):0===d?a.splice(b-c,c+d,[-1,e]):a.splice(b-c-d,c+d,[-1,e],[1,f]),b=b-c-d+(c?1:0)+(d?1:0)+1):0!==b&&0==a[b-1][0]?(a[b-1][1]+=a[b][1],a.splice(b,1)):b++,c=d=0,f=e=""}""===a[a.length-1][1]&&a.pop();c=!1;for(b=1;b<a.length-1;)0==a[b-1][0]&&0==a[b+1][0]&&(a[b][1].substring(a[b][1].length-a[b-1][1].length)==a[b-1][1]?(a[b][1]=a[b-1][1]+a[b][1].substring(0,a[b][1].length-a[b-1][1].length),a[b+1][1]=a[b-1][1]+a[b+1][1],a.splice(b-1,1),c=!0):a[b][1].substring(0, | 432 | g),e=e.substring(0,e.length-g))),0===c?a.splice(b-d,c+d,[1,f]):0===d?a.splice(b-c,c+d,[-1,e]):a.splice(b-c-d,c+d,[-1,e],[1,f]),b=b-c-d+(c?1:0)+(d?1:0)+1):0!==b&&0==a[b-1][0]?(a[b-1][1]+=a[b][1],a.splice(b,1)):b++,c=d=0,f=e=""}""===a[a.length-1][1]&&a.pop();c=!1;for(b=1;b<a.length-1;)0==a[b-1][0]&&0==a[b+1][0]&&(a[b][1].substring(a[b][1].length-a[b-1][1].length)==a[b-1][1]?(a[b][1]=a[b-1][1]+a[b][1].substring(0,a[b][1].length-a[b-1][1].length),a[b+1][1]=a[b-1][1]+a[b+1][1],a.splice(b-1,1),c=!0):a[b][1].substring(0, |
433 | a[b+1][1].length)==a[b+1][1]&&(a[b-1][1]+=a[b+1][1],a[b][1]=a[b][1].substring(a[b+1][1].length)+a[b+1][1],a.splice(b+1,1),c=!0)),b++;c&&this.diff_cleanupMerge(a)};diff_match_patch.prototype.diff_xIndex=function(a,b){var c=0,d=0,e=0,f=0,g;for(g=0;g<a.length;g++){1!==a[g][0]&&(c+=a[g][1].length);-1!==a[g][0]&&(d+=a[g][1].length);if(c>b)break;e=c;f=d}return a.length!=g&&-1===a[g][0]?f:f+(b-e)}; | 433 | a[b+1][1].length)==a[b+1][1]&&(a[b-1][1]+=a[b+1][1],a[b][1]=a[b][1].substring(a[b+1][1].length)+a[b+1][1],a.splice(b+1,1),c=!0)),b++;c&&this.diff_cleanupMerge(a)};diff_match_patch.prototype.diff_xIndex=function(a,b){var c=0,d=0,e=0,f=0,g;for(g=0;g<a.length;g++){1!==a[g][0]&&(c+=a[g][1].length);-1!==a[g][0]&&(d+=a[g][1].length);if(c>b)break;e=c;f=d}return a.length!=g&&-1===a[g][0]?f:f+(b-e)}; |
434 | diff_match_patch.prototype.diff_prettyHtml=function(a){for(var b=[],c=/&/g,d=/</g,e=/>/g,f=/\n/g,g=0;g<a.length;g++){var h=a[g][0],j=a[g][1],j=j.replace(c,"&").replace(d,"<").replace(e,">").replace(f,"<span style=\"color: #dcdcdc;\">¬</span><br>");switch(h){case 1:b[g]='<ins style="background:#ccffcc; text-decoration: none;">'+j+"</ins>";break;case -1:b[g]='<del style="background:#ffffcc; text-decoration: line-through; color: orange;">'+j+"</del>";break;case 0:b[g]="<span>"+j+"</span>"}}return b.join("")}; | 434 | diff_match_patch.prototype.diff_prettyHtml=function(a){for(var b=[],c=/&/g,d=/</g,e=/>/g,f=/\n/g,g=0;g<a.length;g++){var h=a[g][0],j=a[g][1],j=j.replace(c,"&").replace(d,"<").replace(e,">").replace(f,"<span style=\"color: #dcdcdc;\">¬</span><br>");switch(h){case 1:b[g]='<ins style="background:#ccffcc; text-decoration: none;">'+j+"</ins>";break;case -1:b[g]='<del style="background:#ffffcc; text-decoration: line-through; color: orange;">'+j+"</del>";break;case 0:b[g]="<span>"+j+"</span>"}}return b.join("")}; |
435 | diff_match_patch.prototype.diff_text1=function(a){for(var b=[],c=0;c<a.length;c++)1!==a[c][0]&&(b[c]=a[c][1]);return b.join("")};diff_match_patch.prototype.diff_text2=function(a){for(var b=[],c=0;c<a.length;c++)-1!==a[c][0]&&(b[c]=a[c][1]);return b.join("")};diff_match_patch.prototype.diff_levenshtein=function(a){for(var b=0,c=0,d=0,e=0;e<a.length;e++){var f=a[e][0],g=a[e][1];switch(f){case 1:c+=g.length;break;case -1:d+=g.length;break;case 0:b+=Math.max(c,d),d=c=0}}return b+=Math.max(c,d)}; | 435 | diff_match_patch.prototype.diff_text1=function(a){for(var b=[],c=0;c<a.length;c++)1!==a[c][0]&&(b[c]=a[c][1]);return b.join("")};diff_match_patch.prototype.diff_text2=function(a){for(var b=[],c=0;c<a.length;c++)-1!==a[c][0]&&(b[c]=a[c][1]);return b.join("")};diff_match_patch.prototype.diff_levenshtein=function(a){for(var b=0,c=0,d=0,e=0;e<a.length;e++){var f=a[e][0],g=a[e][1];switch(f){case 1:c+=g.length;break;case -1:d+=g.length;break;case 0:b+=Math.max(c,d),d=c=0}}return b+=Math.max(c,d)}; |
436 | diff_match_patch.prototype.diff_toDelta=function(a){for(var b=[],c=0;c<a.length;c++)switch(a[c][0]){case 1:b[c]="+"+encodeURI(a[c][1]);break;case -1:b[c]="-"+a[c][1].length;break;case 0:b[c]="="+a[c][1].length}return b.join("\t").replace(/%20/g," ")}; | 436 | diff_match_patch.prototype.diff_toDelta=function(a){for(var b=[],c=0;c<a.length;c++)switch(a[c][0]){case 1:b[c]="+"+encodeURI(a[c][1]);break;case -1:b[c]="-"+a[c][1].length;break;case 0:b[c]="="+a[c][1].length}return b.join("\t").replace(/%20/g," ")}; |
437 | diff_match_patch.prototype.diff_fromDelta=function(a,b){for(var c=[],d=0,e=0,f=b.split(/\t/g),g=0;g<f.length;g++){var h=f[g].substring(1);switch(f[g].charAt(0)){case "+":try{c[d++]=[1,decodeURI(h)]}catch(j){throw Error("Illegal escape in diff_fromDelta: "+h);}break;case "-":case "=":var i=parseInt(h,10);if(isNaN(i)||0>i)throw Error("Invalid number in diff_fromDelta: "+h);h=a.substring(e,e+=i);"="==f[g].charAt(0)?c[d++]=[0,h]:c[d++]=[-1,h];break;default:if(f[g])throw Error("Invalid diff operation in diff_fromDelta: "+ | 437 | diff_match_patch.prototype.diff_fromDelta=function(a,b){for(var c=[],d=0,e=0,f=b.split(/\t/g),g=0;g<f.length;g++){var h=f[g].substring(1);switch(f[g].charAt(0)){case "+":try{c[d++]=[1,decodeURI(h)]}catch(j){throw Error("Illegal escape in diff_fromDelta: "+h);}break;case "-":case "=":var i=parseInt(h,10);if(isNaN(i)||0>i)throw Error("Invalid number in diff_fromDelta: "+h);h=a.substring(e,e+=i);"="==f[g].charAt(0)?c[d++]=[0,h]:c[d++]=[-1,h];break;default:if(f[g])throw Error("Invalid diff operation in diff_fromDelta: "+ |
438 | f[g]);}}if(e!=a.length)throw Error("Delta length ("+e+") does not equal source text length ("+a.length+").");return c};diff_match_patch.prototype.match_main=function(a,b,c){if(null==a||null==b||null==c)throw Error("Null input. (match_main)");c=Math.max(0,Math.min(c,a.length));return a==b?0:a.length?a.substring(c,c+b.length)==b?c:this.match_bitap_(a,b,c):-1}; | 438 | f[g]);}}if(e!=a.length)throw Error("Delta length ("+e+") does not equal source text length ("+a.length+").");return c};diff_match_patch.prototype.match_main=function(a,b,c){if(null==a||null==b||null==c)throw Error("Null input. (match_main)");c=Math.max(0,Math.min(c,a.length));return a==b?0:a.length?a.substring(c,c+b.length)==b?c:this.match_bitap_(a,b,c):-1}; |
439 | diff_match_patch.prototype.match_bitap_=function(a,b,c){function d(a,d){var e=a/b.length,g=Math.abs(c-d);return!f.Match_Distance?g?1:e:e+g/f.Match_Distance}if(b.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var e=this.match_alphabet_(b),f=this,g=this.Match_Threshold,h=a.indexOf(b,c);-1!=h&&(g=Math.min(d(0,h),g),h=a.lastIndexOf(b,c+b.length),-1!=h&&(g=Math.min(d(0,h),g)));for(var j=1<<b.length-1,h=-1,i,k,p=b.length+a.length,q,s=0;s<b.length;s++){i=0;for(k=p;i<k;)d(s,c+ | 439 | diff_match_patch.prototype.match_bitap_=function(a,b,c){function d(a,d){var e=a/b.length,g=Math.abs(c-d);return!f.Match_Distance?g?1:e:e+g/f.Match_Distance}if(b.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var e=this.match_alphabet_(b),f=this,g=this.Match_Threshold,h=a.indexOf(b,c);-1!=h&&(g=Math.min(d(0,h),g),h=a.lastIndexOf(b,c+b.length),-1!=h&&(g=Math.min(d(0,h),g)));for(var j=1<<b.length-1,h=-1,i,k,p=b.length+a.length,q,s=0;s<b.length;s++){i=0;for(k=p;i<k;)d(s,c+ |
440 | k)<=g?i=k:p=k,k=Math.floor((p-i)/2+i);p=k;i=Math.max(1,c-k+1);var o=Math.min(c+k,a.length)+b.length;k=Array(o+2);for(k[o+1]=(1<<s)-1;o>=i;o--){var v=e[a.charAt(o-1)];k[o]=0===s?(k[o+1]<<1|1)&v:(k[o+1]<<1|1)&v|(q[o+1]|q[o])<<1|1|q[o+1];if(k[o]&j&&(v=d(s,o-1),v<=g))if(g=v,h=o-1,h>c)i=Math.max(1,2*c-h);else break}if(d(s+1,c)>g)break;q=k}return h}; | 440 | k)<=g?i=k:p=k,k=Math.floor((p-i)/2+i);p=k;i=Math.max(1,c-k+1);var o=Math.min(c+k,a.length)+b.length;k=Array(o+2);for(k[o+1]=(1<<s)-1;o>=i;o--){var v=e[a.charAt(o-1)];k[o]=0===s?(k[o+1]<<1|1)&v:(k[o+1]<<1|1)&v|(q[o+1]|q[o])<<1|1|q[o+1];if(k[o]&j&&(v=d(s,o-1),v<=g))if(g=v,h=o-1,h>c)i=Math.max(1,2*c-h);else break}if(d(s+1,c)>g)break;q=k}return h}; |
441 | diff_match_patch.prototype.match_alphabet_=function(a){for(var b={},c=0;c<a.length;c++)b[a.charAt(c)]=0;for(c=0;c<a.length;c++)b[a.charAt(c)]|=1<<a.length-c-1;return b}; | 441 | diff_match_patch.prototype.match_alphabet_=function(a){for(var b={},c=0;c<a.length;c++)b[a.charAt(c)]=0;for(c=0;c<a.length;c++)b[a.charAt(c)]|=1<<a.length-c-1;return b}; |
442 | diff_match_patch.prototype.patch_addContext_=function(a,b){if(0!=b.length){for(var c=b.substring(a.start2,a.start2+a.length1),d=0;b.indexOf(c)!=b.lastIndexOf(c)&&c.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)d+=this.Patch_Margin,c=b.substring(a.start2-d,a.start2+a.length1+d);d+=this.Patch_Margin;(c=b.substring(a.start2-d,a.start2))&&a.diffs.unshift([0,c]);(d=b.substring(a.start2+a.length1,a.start2+a.length1+d))&&a.diffs.push([0,d]);a.start1-=c.length;a.start2-=c.length;a.length1+= | 442 | diff_match_patch.prototype.patch_addContext_=function(a,b){if(0!=b.length){for(var c=b.substring(a.start2,a.start2+a.length1),d=0;b.indexOf(c)!=b.lastIndexOf(c)&&c.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)d+=this.Patch_Margin,c=b.substring(a.start2-d,a.start2+a.length1+d);d+=this.Patch_Margin;(c=b.substring(a.start2-d,a.start2))&&a.diffs.unshift([0,c]);(d=b.substring(a.start2+a.length1,a.start2+a.length1+d))&&a.diffs.push([0,d]);a.start1-=c.length;a.start2-=c.length;a.length1+= |
443 | c.length+d.length;a.length2+=c.length+d.length}}; | 443 | c.length+d.length;a.length2+=c.length+d.length}}; |
444 | diff_match_patch.prototype.patch_make=function(a,b,c){var d;if("string"==typeof a&&"string"==typeof b&&"undefined"==typeof c)d=a,b=this.diff_main(d,b,!0),2<b.length&&(this.diff_cleanupSemantic(b),this.diff_cleanupEfficiency(b));else if(a&&"object"==typeof a&&"undefined"==typeof b&&"undefined"==typeof c)b=a,d=this.diff_text1(b);else if("string"==typeof a&&b&&"object"==typeof b&&"undefined"==typeof c)d=a;else if("string"==typeof a&&"string"==typeof b&&c&&"object"==typeof c)d=a,b=c;else throw Error("Unknown call format to patch_make."); | 444 | diff_match_patch.prototype.patch_make=function(a,b,c){var d;if("string"==typeof a&&"string"==typeof b&&"undefined"==typeof c)d=a,b=this.diff_main(d,b,!0),2<b.length&&(this.diff_cleanupSemantic(b),this.diff_cleanupEfficiency(b));else if(a&&"object"==typeof a&&"undefined"==typeof b&&"undefined"==typeof c)b=a,d=this.diff_text1(b);else if("string"==typeof a&&b&&"object"==typeof b&&"undefined"==typeof c)d=a;else if("string"==typeof a&&"string"==typeof b&&c&&"object"==typeof c)d=a,b=c;else throw Error("Unknown call format to patch_make."); |
445 | if(0===b.length)return[];for(var c=[],a=new diff_match_patch.patch_obj,e=0,f=0,g=0,h=d,j=0;j<b.length;j++){var i=b[j][0],k=b[j][1];if(!e&&0!==i)a.start1=f,a.start2=g;switch(i){case 1:a.diffs[e++]=b[j];a.length2+=k.length;d=d.substring(0,g)+k+d.substring(g);break;case -1:a.length1+=k.length;a.diffs[e++]=b[j];d=d.substring(0,g)+d.substring(g+k.length);break;case 0:k.length<=2*this.Patch_Margin&&e&&b.length!=j+1?(a.diffs[e++]=b[j],a.length1+=k.length,a.length2+=k.length):k.length>=2*this.Patch_Margin&& | 445 | if(0===b.length)return[];for(var c=[],a=new diff_match_patch.patch_obj,e=0,f=0,g=0,h=d,j=0;j<b.length;j++){var i=b[j][0],k=b[j][1];if(!e&&0!==i)a.start1=f,a.start2=g;switch(i){case 1:a.diffs[e++]=b[j];a.length2+=k.length;d=d.substring(0,g)+k+d.substring(g);break;case -1:a.length1+=k.length;a.diffs[e++]=b[j];d=d.substring(0,g)+d.substring(g+k.length);break;case 0:k.length<=2*this.Patch_Margin&&e&&b.length!=j+1?(a.diffs[e++]=b[j],a.length1+=k.length,a.length2+=k.length):k.length>=2*this.Patch_Margin&& |
446 | e&&(this.patch_addContext_(a,h),c.push(a),a=new diff_match_patch.patch_obj,e=0,h=d,f=g)}1!==i&&(f+=k.length);-1!==i&&(g+=k.length)}e&&(this.patch_addContext_(a,h),c.push(a));return c};diff_match_patch.prototype.patch_deepCopy=function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=new diff_match_patch.patch_obj;e.diffs=[];for(var f=0;f<d.diffs.length;f++)e.diffs[f]=d.diffs[f].slice();e.start1=d.start1;e.start2=d.start2;e.length1=d.length1;e.length2=d.length2;b[c]=e}return b}; | 446 | e&&(this.patch_addContext_(a,h),c.push(a),a=new diff_match_patch.patch_obj,e=0,h=d,f=g)}1!==i&&(f+=k.length);-1!==i&&(g+=k.length)}e&&(this.patch_addContext_(a,h),c.push(a));return c};diff_match_patch.prototype.patch_deepCopy=function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=new diff_match_patch.patch_obj;e.diffs=[];for(var f=0;f<d.diffs.length;f++)e.diffs[f]=d.diffs[f].slice();e.start1=d.start1;e.start2=d.start2;e.length1=d.length1;e.length2=d.length2;b[c]=e}return b}; |
447 | diff_match_patch.prototype.patch_apply=function(a,b){if(0==a.length)return[b,[]];var a=this.patch_deepCopy(a),c=this.patch_addPadding(a),b=c+b+c;this.patch_splitMax(a);for(var d=0,e=[],f=0;f<a.length;f++){var g=a[f].start2+d,h=this.diff_text1(a[f].diffs),j,i=-1;if(h.length>this.Match_MaxBits){if(j=this.match_main(b,h.substring(0,this.Match_MaxBits),g),-1!=j&&(i=this.match_main(b,h.substring(h.length-this.Match_MaxBits),g+h.length-this.Match_MaxBits),-1==i||j>=i))j=-1}else j=this.match_main(b,h,g); | 447 | diff_match_patch.prototype.patch_apply=function(a,b){if(0==a.length)return[b,[]];var a=this.patch_deepCopy(a),c=this.patch_addPadding(a),b=c+b+c;this.patch_splitMax(a);for(var d=0,e=[],f=0;f<a.length;f++){var g=a[f].start2+d,h=this.diff_text1(a[f].diffs),j,i=-1;if(h.length>this.Match_MaxBits){if(j=this.match_main(b,h.substring(0,this.Match_MaxBits),g),-1!=j&&(i=this.match_main(b,h.substring(h.length-this.Match_MaxBits),g+h.length-this.Match_MaxBits),-1==i||j>=i))j=-1}else j=this.match_main(b,h,g); |
448 | if(-1==j)e[f]=!1,d-=a[f].length2-a[f].length1;else if(e[f]=!0,d=j-g,g=-1==i?b.substring(j,j+h.length):b.substring(j,i+this.Match_MaxBits),h==g)b=b.substring(0,j)+this.diff_text2(a[f].diffs)+b.substring(j+h.length);else if(g=this.diff_main(h,g,!1),h.length>this.Match_MaxBits&&this.diff_levenshtein(g)/h.length>this.Patch_DeleteThreshold)e[f]=!1;else{this.diff_cleanupSemanticLossless(g);for(var h=0,k,i=0;i<a[f].diffs.length;i++){var p=a[f].diffs[i];0!==p[0]&&(k=this.diff_xIndex(g,h));1===p[0]?b=b.substring(0, | 448 | if(-1==j)e[f]=!1,d-=a[f].length2-a[f].length1;else if(e[f]=!0,d=j-g,g=-1==i?b.substring(j,j+h.length):b.substring(j,i+this.Match_MaxBits),h==g)b=b.substring(0,j)+this.diff_text2(a[f].diffs)+b.substring(j+h.length);else if(g=this.diff_main(h,g,!1),h.length>this.Match_MaxBits&&this.diff_levenshtein(g)/h.length>this.Patch_DeleteThreshold)e[f]=!1;else{this.diff_cleanupSemanticLossless(g);for(var h=0,k,i=0;i<a[f].diffs.length;i++){var p=a[f].diffs[i];0!==p[0]&&(k=this.diff_xIndex(g,h));1===p[0]?b=b.substring(0, |
449 | j+k)+p[1]+b.substring(j+k):-1===p[0]&&(b=b.substring(0,j+k)+b.substring(j+this.diff_xIndex(g,h+p[1].length)));-1!==p[0]&&(h+=p[1].length)}}}b=b.substring(c.length,b.length-c.length);return[b,e]}; | 449 | j+k)+p[1]+b.substring(j+k):-1===p[0]&&(b=b.substring(0,j+k)+b.substring(j+this.diff_xIndex(g,h+p[1].length)));-1!==p[0]&&(h+=p[1].length)}}}b=b.substring(c.length,b.length-c.length);return[b,e]}; |
450 | diff_match_patch.prototype.patch_addPadding=function(a){for(var b=this.Patch_Margin,c="",d=1;d<=b;d++)c+=String.fromCharCode(d);for(d=0;d<a.length;d++)a[d].start1+=b,a[d].start2+=b;var d=a[0],e=d.diffs;if(0==e.length||0!=e[0][0])e.unshift([0,c]),d.start1-=b,d.start2-=b,d.length1+=b,d.length2+=b;else if(b>e[0][1].length){var f=b-e[0][1].length;e[0][1]=c.substring(e[0][1].length)+e[0][1];d.start1-=f;d.start2-=f;d.length1+=f;d.length2+=f}d=a[a.length-1];e=d.diffs;0==e.length||0!=e[e.length-1][0]?(e.push([0, | 450 | diff_match_patch.prototype.patch_addPadding=function(a){for(var b=this.Patch_Margin,c="",d=1;d<=b;d++)c+=String.fromCharCode(d);for(d=0;d<a.length;d++)a[d].start1+=b,a[d].start2+=b;var d=a[0],e=d.diffs;if(0==e.length||0!=e[0][0])e.unshift([0,c]),d.start1-=b,d.start2-=b,d.length1+=b,d.length2+=b;else if(b>e[0][1].length){var f=b-e[0][1].length;e[0][1]=c.substring(e[0][1].length)+e[0][1];d.start1-=f;d.start2-=f;d.length1+=f;d.length2+=f}d=a[a.length-1];e=d.diffs;0==e.length||0!=e[e.length-1][0]?(e.push([0, |
451 | c]),d.length1+=b,d.length2+=b):b>e[e.length-1][1].length&&(f=b-e[e.length-1][1].length,e[e.length-1][1]+=c.substring(0,f),d.length1+=f,d.length2+=f);return c}; | 451 | c]),d.length1+=b,d.length2+=b):b>e[e.length-1][1].length&&(f=b-e[e.length-1][1].length,e[e.length-1][1]+=c.substring(0,f),d.length1+=f,d.length2+=f);return c}; |
452 | diff_match_patch.prototype.patch_splitMax=function(a){for(var b=this.Match_MaxBits,c=0;c<a.length;c++)if(!(a[c].length1<=b)){var d=a[c];a.splice(c--,1);for(var e=d.start1,f=d.start2,g="";0!==d.diffs.length;){var h=new diff_match_patch.patch_obj,j=!0;h.start1=e-g.length;h.start2=f-g.length;if(""!==g)h.length1=h.length2=g.length,h.diffs.push([0,g]);for(;0!==d.diffs.length&&h.length1<b-this.Patch_Margin;){var g=d.diffs[0][0],i=d.diffs[0][1];1===g?(h.length2+=i.length,f+=i.length,h.diffs.push(d.diffs.shift()), | 452 | diff_match_patch.prototype.patch_splitMax=function(a){for(var b=this.Match_MaxBits,c=0;c<a.length;c++)if(!(a[c].length1<=b)){var d=a[c];a.splice(c--,1);for(var e=d.start1,f=d.start2,g="";0!==d.diffs.length;){var h=new diff_match_patch.patch_obj,j=!0;h.start1=e-g.length;h.start2=f-g.length;if(""!==g)h.length1=h.length2=g.length,h.diffs.push([0,g]);for(;0!==d.diffs.length&&h.length1<b-this.Patch_Margin;){var g=d.diffs[0][0],i=d.diffs[0][1];1===g?(h.length2+=i.length,f+=i.length,h.diffs.push(d.diffs.shift()), |
453 | j=!1):-1===g&&1==h.diffs.length&&0==h.diffs[0][0]&&i.length>2*b?(h.length1+=i.length,e+=i.length,j=!1,h.diffs.push([g,i]),d.diffs.shift()):(i=i.substring(0,b-h.length1-this.Patch_Margin),h.length1+=i.length,e+=i.length,0===g?(h.length2+=i.length,f+=i.length):j=!1,h.diffs.push([g,i]),i==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(i.length))}g=this.diff_text2(h.diffs);g=g.substring(g.length-this.Patch_Margin);i=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);""!==i&& | 453 | j=!1):-1===g&&1==h.diffs.length&&0==h.diffs[0][0]&&i.length>2*b?(h.length1+=i.length,e+=i.length,j=!1,h.diffs.push([g,i]),d.diffs.shift()):(i=i.substring(0,b-h.length1-this.Patch_Margin),h.length1+=i.length,e+=i.length,0===g?(h.length2+=i.length,f+=i.length):j=!1,h.diffs.push([g,i]),i==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(i.length))}g=this.diff_text2(h.diffs);g=g.substring(g.length-this.Patch_Margin);i=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);""!==i&& |
454 | (h.length1+=i.length,h.length2+=i.length,0!==h.diffs.length&&0===h.diffs[h.diffs.length-1][0]?h.diffs[h.diffs.length-1][1]+=i:h.diffs.push([0,i]));j||a.splice(++c,0,h)}}};diff_match_patch.prototype.patch_toText=function(a){for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b.join("")}; | 454 | (h.length1+=i.length,h.length2+=i.length,0!==h.diffs.length&&0===h.diffs[h.diffs.length-1][0]?h.diffs[h.diffs.length-1][1]+=i:h.diffs.push([0,i]));j||a.splice(++c,0,h)}}};diff_match_patch.prototype.patch_toText=function(a){for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b.join("")}; |
455 | diff_match_patch.prototype.patch_fromText=function(a){var b=[];if(!a)return b;for(var a=a.split("\n"),c=0,d=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;c<a.length;){var e=a[c].match(d);if(!e)throw Error("Invalid patch string: "+a[c]);var f=new diff_match_patch.patch_obj;b.push(f);f.start1=parseInt(e[1],10);""===e[2]?(f.start1--,f.length1=1):"0"==e[2]?f.length1=0:(f.start1--,f.length1=parseInt(e[2],10));f.start2=parseInt(e[3],10);""===e[4]?(f.start2--,f.length2=1):"0"==e[4]?f.length2=0:(f.start2--,f.length2= | 455 | diff_match_patch.prototype.patch_fromText=function(a){var b=[];if(!a)return b;for(var a=a.split("\n"),c=0,d=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;c<a.length;){var e=a[c].match(d);if(!e)throw Error("Invalid patch string: "+a[c]);var f=new diff_match_patch.patch_obj;b.push(f);f.start1=parseInt(e[1],10);""===e[2]?(f.start1--,f.length1=1):"0"==e[2]?f.length1=0:(f.start1--,f.length1=parseInt(e[2],10));f.start2=parseInt(e[3],10);""===e[4]?(f.start2--,f.length2=1):"0"==e[4]?f.length2=0:(f.start2--,f.length2= |
456 | parseInt(e[4],10));for(c++;c<a.length;){e=a[c].charAt(0);try{var g=decodeURI(a[c].substring(1))}catch(h){throw Error("Illegal escape in patch_fromText: "+g);}if("-"==e)f.diffs.push([-1,g]);else if("+"==e)f.diffs.push([1,g]);else if(" "==e)f.diffs.push([0,g]);else if("@"==e)break;else if(""!==e)throw Error('Invalid patch mode "'+e+'" in: '+g);c++}}return b};diff_match_patch.patch_obj=function(){this.diffs=[];this.start2=this.start1=null;this.length2=this.length1=0}; | 456 | parseInt(e[4],10));for(c++;c<a.length;){e=a[c].charAt(0);try{var g=decodeURI(a[c].substring(1))}catch(h){throw Error("Illegal escape in patch_fromText: "+g);}if("-"==e)f.diffs.push([-1,g]);else if("+"==e)f.diffs.push([1,g]);else if(" "==e)f.diffs.push([0,g]);else if("@"==e)break;else if(""!==e)throw Error('Invalid patch mode "'+e+'" in: '+g);c++}}return b};diff_match_patch.patch_obj=function(){this.diffs=[];this.start2=this.start1=null;this.length2=this.length1=0}; |
457 | diff_match_patch.patch_obj.prototype.toString=function(){var a,b;a=0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1;b=0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2;a=["@@ -"+a+" +"+b+" @@\n"];var c;for(b=0;b<this.diffs.length;b++){switch(this.diffs[b][0]){case 1:c="+";break;case -1:c="-";break;case 0:c=" "}a[b+1]=c+encodeURI(this.diffs[b][1])+"\n"}return a.join("").replace(/%20/g," ")}; | 457 | diff_match_patch.patch_obj.prototype.toString=function(){var a,b;a=0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1;b=0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2;a=["@@ -"+a+" +"+b+" @@\n"];var c;for(b=0;b<this.diffs.length;b++){switch(this.diffs[b][0]){case 1:c="+";break;case -1:c="-";break;case 0:c=" "}a[b+1]=c+encodeURI(this.diffs[b][1])+"\n"}return a.join("").replace(/%20/g," ")}; |
458 | this.diff_match_patch=diff_match_patch;this.DIFF_DELETE=-1;this.DIFF_INSERT=1;this.DIFF_EQUAL=0;})() | 458 | this.diff_match_patch=diff_match_patch;this.DIFF_DELETE=-1;this.DIFF_INSERT=1;this.DIFF_EQUAL=0;})() |
459 | var dmp = new diff_match_patch(); function diffLaunch(){var text1 = document.getElementById('text').value; var text2 = document.getElementById('text2').value; dmp.Diff_Timeout = 0; dmp.Diff_EditCost = 4; var d = dmp.diff_main(text1, text2); var ds = dmp.diff_prettyHtml(d); document.getElementById('diff').innerHTML = ds; | 459 | var dmp = new diff_match_patch(); function diffLaunch(){var text1 = document.getElementById('text').value; var text2 = document.getElementById('text2').value; dmp.Diff_Timeout = 0; dmp.Diff_EditCost = 4; var d = dmp.diff_main(text1, text2); var ds = dmp.diff_prettyHtml(d); document.getElementById('diff').innerHTML = ds; |
460 | } | 460 | } |
461 | //--><!]]></script> | 461 | //--><!]]></script> |
462 | <title>htmLawed (<?php echo hl_version();?>) test</title> | 462 | <title>htmLawed (<?php echo hl_version();?>) test</title> |
463 | </head> | 463 | </head> |
464 | <body> | 464 | <body> |
465 | <div id="topmost"> | 465 | <div id="topmost"> |
466 | 466 | ||
467 | <h5 style="float: left; display: inline; margin-top: 0; margin-bottom: 5px;"><a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php" title="htmLawed home">HTM<big><big>L</big></big>AWED</a> <?php echo hl_version();?> <a href="htmLawedTest.php" title="test home">TEST</a></h5> | 467 | <h5 style="float: left; display: inline; margin-top: 0; margin-bottom: 5px;"><a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php" title="htmLawed home">HTM<big><big>L</big></big>AWED</a> <?php echo hl_version();?> <a href="htmLawedTest.php" title="test home">TEST</a></h5> |
468 | <span style="float: right;" class="help"><a href="htmLawed_README.htm"><span class="notice">htm</span></a> / <a href="htmLawed_README.txt"><span class="notice">txt</span></a> documentation</span><br style="clear:both;" /> | 468 | <span style="float: right;" class="help"><a href="htmLawed_README.htm"><span class="notice">htm</span></a> / <a href="htmLawed_README.txt"><span class="notice">txt</span></a> documentation</span><br style="clear:both;" /> |
469 | 469 | ||
470 | <a href="htmLawedTest.php" title="[toggle visibility] type or copy-paste" onclick="javascript:toggle('inputF'); return false;"><span class="notice">Input »</span> <span class="help" title="limit lower with multibyte characters<?php echo (($_hlimit < $_limit && $_hlimit)? '; limit is '. $_hlimit. ' for viewing binaries' : ''); ?>"><small>(max. <?php echo htmlspecialchars($_limit);?> chars)</small></span></a> | 470 | <a href="htmLawedTest.php" title="[toggle visibility] type or copy-paste" onclick="javascript:toggle('inputF'); return false;"><span class="notice">Input »</span> <span class="help" title="limit lower with multibyte characters<?php echo (($_hlimit < $_limit && $_hlimit)? '; limit is '. $_hlimit. ' for viewing binaries' : ''); ?>"><small>(max. <?php echo htmlspecialchars($_limit);?> chars)</small></span></a> |
471 | 471 | ||
472 | <form id="testform" name="testform" action="htmLawedTest.php" method="post" accept-charset="<?php echo htmlspecialchars($_POST['enc']); ?>" style="padding:0; margin: 0; display:inline;"> | 472 | <form id="testform" name="testform" action="htmLawedTest.php" method="post" accept-charset="<?php echo htmlspecialchars($_POST['enc']); ?>" style="padding:0; margin: 0; display:inline;"> |
473 | 473 | ||
474 | <div id="inputF" style="display: block;"> | 474 | <div id="inputF" style="display: block;"> |
475 | 475 | ||
476 | <input type="hidden" name="token" id="token" value="<?php echo $token; ?>" /> | 476 | <input type="hidden" name="token" id="token" value="<?php echo $token; ?>" /> |
477 | <div><textarea id="text" class="textarea" name="text" rows="5" cols="100" style="width: 100%;"><?php echo htmlspecialchars($_POST['text']);?></textarea></div> | 477 | <div><textarea id="text" class="textarea" name="text" rows="5" cols="100" style="width: 100%;"><?php echo htmlspecialchars($_POST['text']);?></textarea></div> |
478 | <input type="submit" id="submitF" name="submitF" value="Process" style="float:left;" title="filter using htmLawed" onclick="javascript: sndProc(); return false;" onkeypress="javascript: sndProc(); return false;" /> | 478 | <input type="submit" id="submitF" name="submitF" value="Process" style="float:left;" title="filter using htmLawed" onclick="javascript: sndProc(); return false;" onkeypress="javascript: sndProc(); return false;" /> |
479 | 479 | ||
480 | <?php | 480 | <?php |
481 | if($do){ | 481 | if($do){ |
482 | if($validation){ | 482 | if($validation){ |
483 | echo '<input type="hidden" value="1" name="w3c_validate" id="w3c_validate" />'; | 483 | echo '<input type="hidden" value="1" name="w3c_validate" id="w3c_validate" />'; |
484 | } | 484 | } |
485 | ?> | 485 | ?> |
486 | 486 | ||
487 | <button type="button" title="Raw input rendered as web-page without a doctype or charset declaration" style="float: right;" onclick="javascript: sndUnproc(); return false;" onkeypress="javascript: sndUnproc(); return false;">Render in webpage</button> | 487 | <button type="button" title="Raw input rendered as web-page without a doctype or charset declaration" style="float: right;" onclick="javascript: sndUnproc(); return false;" onkeypress="javascript: sndUnproc(); return false;">Render in webpage</button> |
488 | <button type="button" onclick="javascript:document.getElementById('text').focus();document.getElementById('text').select()" title="select all to copy" style="float:right;">Select all</button> | 488 | <button type="button" onclick="javascript:document.getElementById('text').focus();document.getElementById('text').select()" title="select all to copy" style="float:right;">Select all</button> |
489 | 489 | ||
490 | <?php | 490 | <?php |
491 | if($_w3c_validate && $validation){ | 491 | if($_w3c_validate && $validation){ |
492 | ?> | 492 | ?> |
493 | 493 | ||
494 | <button type="button" title="HTML 4.01 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text', 'html401'); return false;" onkeypress="javascript: sndValidn('text', 'html401'); return false;">Check HTML</button> | 494 | <button type="button" title="HTML 4.01 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text', 'html401'); return false;" onkeypress="javascript: sndValidn('text', 'html401'); return false;">Check HTML</button> |
495 | <button type="button" title="XHTML 1.1 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text', 'xhtml110'); return false;" onkeypress="javascript: sndValidn('text', 'xhtml110'); return false;">Check XHTML</button> | 495 | <button type="button" title="XHTML 1.1 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text', 'xhtml110'); return false;" onkeypress="javascript: sndValidn('text', 'xhtml110'); return false;">Check XHTML</button> |
496 | 496 | ||
497 | <?php | 497 | <?php |
498 | } | 498 | } |
499 | } | 499 | } |
500 | else{ | 500 | else{ |
501 | if($_w3c_validate){ | 501 | if($_w3c_validate){ |
502 | echo '<span style="float: right;" class="help" title="for direct submission of input or output code to W3C validator for (X)HTML validation"><span style="font-size: 85%;"> Validator tools: </span><input type="checkbox" value="1" name="w3c_validate" id="w3c_validate" style="vertical-align: middle;"', ($validation ? ' checked="checked"' : ''), ' /></span>'; | 502 | echo '<span style="float: right;" class="help" title="for direct submission of input or output code to W3C validator for (X)HTML validation"><span style="font-size: 85%;"> Validator tools: </span><input type="checkbox" value="1" name="w3c_validate" id="w3c_validate" style="vertical-align: middle;"', ($validation ? ' checked="checked"' : ''), ' /></span>'; |
503 | } | 503 | } |
504 | } | 504 | } |
505 | ?> | 505 | ?> |
506 | 506 | ||
507 | <span style="float:right;" class="help" title="IANA-recognized name of the input character-set; can be multiple ;- or space-separated values; may not work in some browsers"><span style="font-size: 85%;">Encoding: </span><input type="text" size="8" id="enc" name="enc" style="vertical-align: middle;" value="<?php echo htmlspecialchars($_POST['enc']); ?>" /></span> | 507 | <span style="float:right;" class="help" title="IANA-recognized name of the input character-set; can be multiple ;- or space-separated values; may not work in some browsers"><span style="font-size: 85%;">Encoding: </span><input type="text" size="8" id="enc" name="enc" style="vertical-align: middle;" value="<?php echo htmlspecialchars($_POST['enc']); ?>" /></span> |
508 | 508 | ||
509 | </div> | 509 | </div> |
510 | <br style="clear:both;" /> | 510 | <br style="clear:both;" /> |
511 | 511 | ||
512 | <?php | 512 | <?php |
513 | if($limit_exceeded){ | 513 | if($limit_exceeded){ |
514 | echo '<br /><strong>Input text is too long!</strong><br />'; | 514 | echo '<br /><strong>Input text is too long!</strong><br />'; |
515 | } | 515 | } |
516 | ?> | 516 | ?> |
517 | 517 | ||
518 | <br /> | 518 | <br /> |
519 | 519 | ||
520 | <a href="htmLawedTest.php" title="[toggle visibility] htmLawed configuration" onclick="javascript:toggle('inputC'); return false;"><span class="notice">Settings »</span></a> | 520 | <a href="htmLawedTest.php" title="[toggle visibility] htmLawed configuration" onclick="javascript:toggle('inputC'); return false;"><span class="notice">Settings »</span></a> |
521 | 521 | ||
522 | <div id="inputC" style="display: none;"> | 522 | <div id="inputC" style="display: none;"> |
523 | <table summary="none"> | 523 | <table summary="none"> |
524 | <tr> | 524 | <tr> |
525 | <td><span class="help" title="$config argument">Config:</span></td> | 525 | <td><span class="help" title="$config argument">Config:</span></td> |
526 | <td><ul> | 526 | <td><ul> |
527 | 527 | ||
528 | <?php | 528 | <?php |
529 | $cfg = array( | 529 | $cfg = array( |
530 | 'abs_url'=>array('3', '0', 'absolute/relative URL conversion', '-1'), | 530 | 'abs_url'=>array('3', '0', 'absolute/relative URL conversion', '-1'), |
531 | 'and_mark'=>array('2', '0', 'mark original <em>&</em> chars', '0', 'd'=>1), // 'd' to disable | 531 | 'and_mark'=>array('2', '0', 'mark original <em>&</em> chars', '0', 'd'=>1), // 'd' to disable |
532 | 'anti_link_spam'=>array('1', '0', 'modify <em>href</em> values as an anti-link spam measure', '0', array(array('30', '1', '', 'regex for extra <em>rel</em>'), array('30', '2', '', 'regex for no <em>href</em>'))), | 532 | 'anti_link_spam'=>array('1', '0', 'modify <em>href</em> values as an anti-link spam measure', '0', array(array('30', '1', '', 'regex for extra <em>rel</em>'), array('30', '2', '', 'regex for no <em>href</em>'))), |
533 | 'anti_mail_spam'=>array('1', '0', 'replace <em>@</em> in <em>mailto:</em> URLs', '0', '8', 'NO@SPAM', 'replacement'), | 533 | 'anti_mail_spam'=>array('1', '0', 'replace <em>@</em> in <em>mailto:</em> URLs', '0', '8', 'NO@SPAM', 'replacement'), |
534 | 'balance'=>array('2', '1', 'fix nestings and balance tags', '0'), | 534 | 'balance'=>array('2', '1', 'fix nestings and balance tags', '0'), |
535 | 'base_url'=>array('', '', 'base URL', '25'), | 535 | 'base_url'=>array('', '', 'base URL', '25'), |
536 | 'cdata'=>array('4', 'nil', 'allow <em>CDATA</em> sections', 'nil'), | 536 | 'cdata'=>array('4', 'nil', 'allow <em>CDATA</em> sections', 'nil'), |
537 | 'clean_ms_char'=>array('3', '0', 'replace bad characters introduced by Microsoft apps. like <em>Word</em>', '0'), | 537 | 'clean_ms_char'=>array('3', '0', 'replace bad characters introduced by Microsoft apps. like <em>Word</em>', '0'), |
538 | 'comment'=>array('4', 'nil', 'allow HTML comments', 'nil'), | 538 | 'comment'=>array('4', 'nil', 'allow HTML comments', 'nil'), |
539 | 'css_expression'=>array('2', 'nil', 'allow dynamic expressions in CSS style properties', 'nil'), | 539 | 'css_expression'=>array('2', 'nil', 'allow dynamic expressions in CSS style properties', 'nil'), |
540 | 'deny_attribute'=>array('1', '0', 'denied attributes', '0', '50', '', 'these'), | 540 | 'deny_attribute'=>array('1', '0', 'denied attributes', '0', '50', '', 'these'), |
541 | 'direct_list_nest'=>array('2', 'nil', 'allow direct nesting of a list within another without requiring it to be a list item', 'nil'), | 541 | 'direct_list_nest'=>array('2', 'nil', 'allow direct nesting of a list within another without requiring it to be a list item', 'nil'), |
542 | 'elements'=>array('', '', 'allowed elements', '50'), | 542 | 'elements'=>array('', '', 'allowed elements', '50'), |
543 | 'hexdec_entity'=>array('3', '1', 'convert hexadecimal numeric entities to decimal ones, or vice versa', '0'), | 543 | 'hexdec_entity'=>array('3', '1', 'convert hexadecimal numeric entities to decimal ones, or vice versa', '0'), |
544 | 'hook'=>array('', '', 'name of hook function', '25'), | 544 | 'hook'=>array('', '', 'name of hook function', '25'), |
545 | 'hook_tag'=>array('', '', 'name of custom function to further check attribute values', '25'), | 545 | 'hook_tag'=>array('', '', 'name of custom function to further check attribute values', '25'), |
546 | 'keep_bad'=>array('7', '6', 'keep, or remove <em>bad</em> tag content', '0'), | 546 | 'keep_bad'=>array('7', '6', 'keep, or remove <em>bad</em> tag content', '0'), |
547 | 'lc_std_val'=>array('2', '1', 'lower-case std. attribute values like <em>radio</em>', '0'), | 547 | 'lc_std_val'=>array('2', '1', 'lower-case std. attribute values like <em>radio</em>', '0'), |
548 | 'make_tag_strict'=>array('3', 'nil', 'transform deprecated elements', 'nil'), | 548 | 'make_tag_strict'=>array('3', 'nil', 'transform deprecated elements', 'nil'), |
549 | 'named_entity'=>array('2', '1', 'allow named entities, or convert numeric ones', '0'), | 549 | 'named_entity'=>array('2', '1', 'allow named entities, or convert numeric ones', '0'), |
550 | 'no_deprecated_attr'=>array('3', '1', 'allow deprecated attributes, or transform them', '0'), | 550 | 'no_deprecated_attr'=>array('3', '1', 'allow deprecated attributes, or transform them', '0'), |
551 | 'parent'=>array('', 'div', 'name of parent element', '25'), | 551 | 'parent'=>array('', 'div', 'name of parent element', '25'), |
552 | 'safe'=>array('2', '0', 'for most <em>safe</em> HTML', '0'), | 552 | 'safe'=>array('2', '0', 'for most <em>safe</em> HTML', '0'), |
553 | 'schemes'=>array('', 'href: aim, app, feed, file, ftp, gopher, http, https, irc, javascript, mailto, news, nntp, sftp, ssh, telnet, tel; *:data, file, http, https, javascript', 'allowed URL protocols', '50'), | 553 | 'schemes'=>array('', 'href: aim, app, feed, file, ftp, gopher, http, https, irc, javascript, mailto, news, nntp, sftp, ssh, telnet, tel; *:data, file, http, https, javascript', 'allowed URL protocols', '50'), |
554 | 'show_setting'=>array('', 'htmLawed_setting', 'variable name to record <em>finalized</em> htmLawed settings', '25', 'd'=>1), | 554 | 'show_setting'=>array('', 'htmLawed_setting', 'variable name to record <em>finalized</em> htmLawed settings', '25', 'd'=>1), |
555 | 'style_pass'=>array('2', 'nil', 'do not look at <em>style</em> attribute values', 'nil'), | 555 | 'style_pass'=>array('2', 'nil', 'do not look at <em>style</em> attribute values', 'nil'), |
556 | 'tidy'=>array('3', '0', 'beautify/compact', '-1', '8', '1t1', 'format'), | 556 | 'tidy'=>array('3', '0', 'beautify/compact', '-1', '8', '1t1', 'format'), |
557 | 'unique_ids'=>array('2', '1', 'unique <em>id</em> values', '0', '8', 'my_', 'prefix'), | 557 | 'unique_ids'=>array('2', '1', 'unique <em>id</em> values', '0', '8', 'my_', 'prefix'), |
558 | 'valid_xhtml'=>array('2', 'nil', 'auto-set various parameters for most valid XHTML', 'nil'), | 558 | 'valid_xhtml'=>array('2', 'nil', 'auto-set various parameters for most valid XHTML', 'nil'), |
559 | 'xml:lang'=>array('3', 'nil', 'auto-add <em>xml:lang</em> attribute', '0'), | 559 | 'xml:lang'=>array('3', 'nil', 'auto-add <em>xml:lang</em> attribute', '0'), |
560 | ); | 560 | ); |
561 | foreach($cfg as $k=>$v){ | 561 | foreach($cfg as $k=>$v){ |
562 | echo '<li>', $k, ': '; | 562 | echo '<li>', $k, ': '; |
563 | if(!empty($v[0])){ // input radio | 563 | if(!empty($v[0])){ // input radio |
564 | $j = $v[3]; | 564 | $j = $v[3]; |
565 | for($i = $j-1; ++$i < $v[0]+$v[3];++$j){ | 565 | for($i = $j-1; ++$i < $v[0]+$v[3];++$j){ |
566 | echo '<input type="radio" name="h', $k, '" value="', $i, '"', (!isset($_POST['h'. $k]) ? ($v[1] == $i ? ' checked="checked"' : '') : ($_POST['h'. $k] == $i ? ' checked="checked"' : '')), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />', $i, ' '; | 566 | echo '<input type="radio" name="h', $k, '" value="', $i, '"', (!isset($_POST['h'. $k]) ? ($v[1] == $i ? ' checked="checked"' : '') : ($_POST['h'. $k] == $i ? ' checked="checked"' : '')), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />', $i, ' '; |
567 | } | 567 | } |
568 | if($v[1] == 'nil'){ | 568 | if($v[1] == 'nil'){ |
569 | echo '<input type="radio" name="h', $k, '" value="nil"', ((!isset($_POST['h'. $k]) or $_POST['h'. $k] == 'nil') ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />not set '; | 569 | echo '<input type="radio" name="h', $k, '" value="nil"', ((!isset($_POST['h'. $k]) or $_POST['h'. $k] == 'nil') ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />not set '; |
570 | } | 570 | } |
571 | if(!empty($v[4])){ // + input text box | 571 | if(!empty($v[4])){ // + input text box |
572 | echo '<input type="radio" name="h', $k, '" value="', $j, '"', (((isset($_POST['h'. $k]) && $_POST['h'. $k] == $j) or (!isset($_POST['h'. $k]) && $j == $v[1])) ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; | 572 | echo '<input type="radio" name="h', $k, '" value="', $j, '"', (((isset($_POST['h'. $k]) && $_POST['h'. $k] == $j) or (!isset($_POST['h'. $k]) && $j == $v[1])) ? ' checked="checked"' : ''), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; |
573 | if(!is_array($v[4])){ | 573 | if(!is_array($v[4])){ |
574 | echo $v[6], ': <input type="text" size="', $v[4], '" name="h', $k. $j, '" value="', htmlspecialchars(isset($_POST['h'. $k. $j][0]) ? $_POST['h'. $k. $j] : $v[5]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; | 574 | echo $v[6], ': <input type="text" size="', $v[4], '" name="h', $k. $j, '" value="', htmlspecialchars(isset($_POST['h'. $k. $j][0]) ? $_POST['h'. $k. $j] : $v[5]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; |
575 | } | 575 | } |
576 | else{ | 576 | else{ |
577 | foreach($v[4] as $z){ | 577 | foreach($v[4] as $z){ |
578 | echo ' ', $z[3], ': <input type="text" size="', $z[0], '" name="h', $k. $j. $z[1], '" value="', htmlspecialchars(isset($_POST['h'. $k. $j. $z[1]][0]) ? $_POST['h'. $k. $j. $z[1]] : $z[2]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; | 578 | echo ' ', $z[3], ': <input type="text" size="', $z[0], '" name="h', $k. $j. $z[1], '" value="', htmlspecialchars(isset($_POST['h'. $k. $j. $z[1]][0]) ? $_POST['h'. $k. $j. $z[1]] : $z[2]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; |
579 | } | 579 | } |
580 | } | 580 | } |
581 | } | 581 | } |
582 | } | 582 | } |
583 | elseif(ctype_digit($v[3])){ // input text | 583 | elseif(ctype_digit($v[3])){ // input text |
584 | echo '<input type="text" size="', $v[3], '" name="h', $k, '" value="', htmlspecialchars(isset($_POST['h'. $k][0]) ? $_POST['h'. $k] : $v[1]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; | 584 | echo '<input type="text" size="', $v[3], '" name="h', $k, '" value="', htmlspecialchars(isset($_POST['h'. $k][0]) ? $_POST['h'. $k] : $v[1]), '"', (isset($v['d']) ? ' disabled="disabled"' : ''), ' />'; |
585 | } | 585 | } |
586 | else{} // text-area | 586 | else{} // text-area |
587 | echo ' <span class="help">', $v[2], '</span></li>'; | 587 | echo ' <span class="help">', $v[2], '</span></li>'; |
588 | } | 588 | } |
589 | echo '</ul></td></tr><tr><td><span style="vertical-align: top;" class="help" title="$spec argument: element-specific attribute rules">Spec:</span></td><td><textarea name="spec" id="spec" cols="70" rows="3" style="width:80%;">', htmlspecialchars((isset($_POST['spec']) ? $_POST['spec'] : '')), '</textarea></td></tr></table>'; | 589 | echo '</ul></td></tr><tr><td><span style="vertical-align: top;" class="help" title="$spec argument: element-specific attribute rules">Spec:</span></td><td><textarea name="spec" id="spec" cols="70" rows="3" style="width:80%;">', htmlspecialchars((isset($_POST['spec']) ? $_POST['spec'] : '')), '</textarea></td></tr></table>'; |
590 | ?> | 590 | ?> |
591 | 591 | ||
592 | </div> | 592 | </div> |
593 | </form> | 593 | </form> |
594 | 594 | ||
595 | <?php | 595 | <?php |
596 | if($do){ | 596 | if($do){ |
597 | $cfg = array(); | 597 | $cfg = array(); |
598 | foreach($_POST as $k=>$v){ | 598 | foreach($_POST as $k=>$v){ |
599 | if($k[0] == 'h' && $v != 'nil'){ | 599 | if($k[0] == 'h' && $v != 'nil'){ |
600 | $cfg[substr($k, 1)] = $v; | 600 | $cfg[substr($k, 1)] = $v; |
601 | } | 601 | } |
602 | } | 602 | } |
603 | 603 | ||
604 | if(isset($cfg['anti_link_spam']) && $cfg['anti_link_spam'] && (!empty($cfg['anti_link_spam11']) or !empty($cfg['anti_link_spam12']))){ | 604 | if(isset($cfg['anti_link_spam']) && $cfg['anti_link_spam'] && (!empty($cfg['anti_link_spam11']) or !empty($cfg['anti_link_spam12']))){ |
605 | $cfg['anti_link_spam'] = array($cfg['anti_link_spam11'], $cfg['anti_link_spam12']); | 605 | $cfg['anti_link_spam'] = array($cfg['anti_link_spam11'], $cfg['anti_link_spam12']); |
606 | } | 606 | } |
607 | unset($cfg['anti_link_spam11'], $cfg['anti_link_spam12']); | 607 | unset($cfg['anti_link_spam11'], $cfg['anti_link_spam12']); |
608 | if(isset($cfg['anti_mail_spam']) && $cfg['anti_mail_spam'] == 1){ | 608 | if(isset($cfg['anti_mail_spam']) && $cfg['anti_mail_spam'] == 1){ |
609 | $cfg['anti_mail_spam'] = isset($cfg['anti_mail_spam1'][0]) ? $cfg['anti_mail_spam1'] : 0; | 609 | $cfg['anti_mail_spam'] = isset($cfg['anti_mail_spam1'][0]) ? $cfg['anti_mail_spam1'] : 0; |
610 | } | 610 | } |
611 | unset($cfg['anti_mail_spam11']); | 611 | unset($cfg['anti_mail_spam11']); |
612 | if(isset($cfg['deny_attribute']) && $cfg['deny_attribute'] == 1){ | 612 | if(isset($cfg['deny_attribute']) && $cfg['deny_attribute'] == 1){ |
613 | $cfg['deny_attribute'] = isset($cfg['deny_attribute1'][0]) ? $cfg['deny_attribute1'] : 0; | 613 | $cfg['deny_attribute'] = isset($cfg['deny_attribute1'][0]) ? $cfg['deny_attribute1'] : 0; |
614 | } | 614 | } |
615 | unset($cfg['deny_attribute1']); | 615 | unset($cfg['deny_attribute1']); |
616 | if(isset($cfg['tidy']) && $cfg['tidy'] == 2){ | 616 | if(isset($cfg['tidy']) && $cfg['tidy'] == 2){ |
617 | $cfg['tidy'] = isset($cfg['tidy2'][0]) ? $cfg['tidy2'] : 0; | 617 | $cfg['tidy'] = isset($cfg['tidy2'][0]) ? $cfg['tidy2'] : 0; |
618 | } | 618 | } |
619 | unset($cfg['tidy2']); | 619 | unset($cfg['tidy2']); |
620 | if(isset($cfg['unique_ids']) && $cfg['unique_ids'] == 2){ | 620 | if(isset($cfg['unique_ids']) && $cfg['unique_ids'] == 2){ |
621 | $cfg['unique_ids'] = isset($cfg['unique_ids2'][0]) ? $cfg['unique_ids2'] : 1; | 621 | $cfg['unique_ids'] = isset($cfg['unique_ids2'][0]) ? $cfg['unique_ids2'] : 1; |
622 | } | 622 | } |
623 | unset($cfg['unique_ids2']); | 623 | unset($cfg['unique_ids2']); |
624 | unset($cfg['and_mark']); // disabling and_mark | 624 | unset($cfg['and_mark']); // disabling and_mark |
625 | 625 | ||
626 | $cfg['show_setting'] = 'hlcfg'; | 626 | $cfg['show_setting'] = 'hlcfg'; |
627 | $st = microtime(); | 627 | $st = microtime(); |
628 | $out = htmLawed($_POST['text'], $cfg, $_POST['spec']); | 628 | $out = htmLawed($_POST['text'], $cfg, $_POST['spec']); |
629 | $et = microtime(); | 629 | $et = microtime(); |
630 | echo '<br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'inputR\'); return false;"><span class="notice">Input code »</span></a> <span class="help" title="tags estimated as half of total > and < chars; values may be inaccurate for non-ASCII text"><small><big>', strlen($_POST['text']), '</big> chars, ~<big>', ($tag = round((substr_count($_POST['text'], '>') + substr_count($_POST['text'], '<'))/2)), '</big> tag', ($tag > 1 ? 's' : ''), '</small> </span><div id="inputR" style="display: none;">', format($_POST['text']), '</div><script type="text/javascript">hl(\'inputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'inputD\'); return false;"><span class="notice">Input binary » </span></a><div id="inputD" style="display: none;">'. hexdump($_POST['text']). '</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] finalized internal settings as interpreted by htmLawed; for developers" onclick="javascript:toggle(\'settingF\'); return false;"><span class="notice">Finalized internal settings » </span></a> <div id="settingF" style="display: none;">$config: ', str_replace(array(' ', "\t", ' '), array(' ', ' ', ' '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['config'], true)))), '<br />$spec: ', str_replace(array(' ', "\t", ' '), array(' ', ' ', ' '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['spec'], true)))), '</div><script type="text/javascript">hl(\'settingF\');</script>', '<br /><a href="htmLawedTest.php" title="[toggle visibility] suitable for copy-paste" onclick="javascript:toggle(\'outputF\'); return false;"><span class="notice">Output »</span></a> <span class="help" title="approx., server-specific value excluding the \'include()\' call"><small>htmLawed processing time <big>', number_format(((substr($et,0,9)) + (substr($et,-10)) - (substr($st,0,9)) - (substr($st,-10))),4), '</big> s</small></span>', (($mem = memory_get_peak_usage()) !== false ? '<span class="help"><small>, peak memory usage <big>'. round(($mem-$pre_mem)/1048576, 2). '</big> <small>MB</small>' : ''), '</small></span><div id="outputF" style="display: block;"><div><textarea id="text2" class="textarea" name="text2" rows="5" cols="100" style="width: 100%;">', htmlspecialchars($out), '</textarea></div><button type="button" title="Filtered input rendered as web-page without a doctype or charset declaration" style="float: right;" onclick="javascript: sndProc2(); return false;" onkeypress="javascript: sndProc2(); return false;">Render in webpage</button><button type="button" onclick="javascript:document.getElementById(\'text2\').focus();document.getElementById(\'text2\').select()" title="select all to copy" style="float:right;">Select all</button>'; | 630 | echo '<br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'inputR\'); return false;"><span class="notice">Input code »</span></a> <span class="help" title="tags estimated as half of total > and < chars; values may be inaccurate for non-ASCII text"><small><big>', strlen($_POST['text']), '</big> chars, ~<big>', ($tag = round((substr_count($_POST['text'], '>') + substr_count($_POST['text'], '<'))/2)), '</big> tag', ($tag > 1 ? 's' : ''), '</small> </span><div id="inputR" style="display: none;">', format($_POST['text']), '</div><script type="text/javascript">hl(\'inputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'inputD\'); return false;"><span class="notice">Input binary » </span></a><div id="inputD" style="display: none;">'. hexdump($_POST['text']). '</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] finalized internal settings as interpreted by htmLawed; for developers" onclick="javascript:toggle(\'settingF\'); return false;"><span class="notice">Finalized internal settings » </span></a> <div id="settingF" style="display: none;">$config: ', str_replace(array(' ', "\t", ' '), array(' ', ' ', ' '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['config'], true)))), '<br />$spec: ', str_replace(array(' ', "\t", ' '), array(' ', ' ', ' '), nl2br(htmlspecialchars(print_r($GLOBALS['hlcfg']['spec'], true)))), '</div><script type="text/javascript">hl(\'settingF\');</script>', '<br /><a href="htmLawedTest.php" title="[toggle visibility] suitable for copy-paste" onclick="javascript:toggle(\'outputF\'); return false;"><span class="notice">Output »</span></a> <span class="help" title="approx., server-specific value excluding the \'include()\' call"><small>htmLawed processing time <big>', number_format(((substr($et,0,9)) + (substr($et,-10)) - (substr($st,0,9)) - (substr($st,-10))),4), '</big> s</small></span>', (($mem = memory_get_peak_usage()) !== false ? '<span class="help"><small>, peak memory usage <big>'. round(($mem-$pre_mem)/1048576, 2). '</big> <small>MB</small>' : ''), '</small></span><div id="outputF" style="display: block;"><div><textarea id="text2" class="textarea" name="text2" rows="5" cols="100" style="width: 100%;">', htmlspecialchars($out), '</textarea></div><button type="button" title="Filtered input rendered as web-page without a doctype or charset declaration" style="float: right;" onclick="javascript: sndProc2(); return false;" onkeypress="javascript: sndProc2(); return false;">Render in webpage</button><button type="button" onclick="javascript:document.getElementById(\'text2\').focus();document.getElementById(\'text2\').select()" title="select all to copy" style="float:right;">Select all</button>'; |
631 | if($_w3c_validate && $validation) | 631 | if($_w3c_validate && $validation) |
632 | { | 632 | { |
633 | ?> | 633 | ?> |
634 | 634 | ||
635 | <button type="button" title="HTML 4.01 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text2', 'html401'); return false;" onkeypress="javascript: sndValidn('text2', 'html401'); return false;">Check HTML</button> | 635 | <button type="button" title="HTML 4.01 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text2', 'html401'); return false;" onkeypress="javascript: sndValidn('text2', 'html401'); return false;">Check HTML</button> |
636 | <button type="button" title="XHTML 1.1 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text2', 'xhtml110'); return false;" onkeypress="javascript: sndValidn('text2', 'xhtml110'); return false;">Check XHTML</button> | 636 | <button type="button" title="XHTML 1.1 W3C online validation" style="float: right;" onclick="javascript: sndValidn('text2', 'xhtml110'); return false;" onkeypress="javascript: sndValidn('text2', 'xhtml110'); return false;">Check XHTML</button> |
637 | 637 | ||
638 | <?php | 638 | <?php |
639 | } | 639 | } |
640 | echo '</div><br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'outputR\'); return false;"><span class="notice">Output code »</span></a><div id="outputR" style="display: block;">', format($out), '</div><script type="text/javascript">hl(\'outputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'outputD\'); return false;"><span class="notice">Output binary »</span></a><div id="outputD" style="display: none;">'. hexdump($out). '</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] inline output-input diff; might not be perfectly accurate, semantically or otherwise " onclick="javascript:toggle(\'diff\'); diffLaunch(); return false;"><span class="notice">Diff »</span></a> <div id="diff" style="display: none;"></div><br /><a href="htmLawedTest.php" title="[toggle visibility] XHTML 1 Transitional doctype" onclick="javascript:toggle(\'outputH\'); return false;">'; | 640 | echo '</div><br /><a href="htmLawedTest.php" title="[toggle visibility] syntax-highlighted" onclick="javascript:toggle(\'outputR\'); return false;"><span class="notice">Output code »</span></a><div id="outputR" style="display: block;">', format($out), '</div><script type="text/javascript">hl(\'outputR\');</script>', (!isset($_POST['text'][$_hlimit]) ? ' <a href="htmLawedTest.php" title="[toggle visibility] hexdump; non-viewable characters like line-returns are shown as dots" onclick="javascript:toggle(\'outputD\'); return false;"><span class="notice">Output binary »</span></a><div id="outputD" style="display: none;">'. hexdump($out). '</div>' : ''), ' <a href="htmLawedTest.php" title="[toggle visibility] inline output-input diff; might not be perfectly accurate, semantically or otherwise " onclick="javascript:toggle(\'diff\'); diffLaunch(); return false;"><span class="notice">Diff »</span></a> <div id="diff" style="display: none;"></div><br /><a href="htmLawedTest.php" title="[toggle visibility] XHTML 1 Transitional doctype" onclick="javascript:toggle(\'outputH\'); return false;">'; |
641 | } | 641 | } |
642 | else{ | 642 | else{ |
643 | ?> | 643 | ?> |
644 | 644 | ||
645 | <br /> | 645 | <br /> |
646 | 646 | ||
647 | <div class="help">Use with a Javascript- and cookie-enabled, relatively new version of a common browser. | 647 | <div class="help">Use with a Javascript- and cookie-enabled, relatively new version of a common browser. |
648 | 648 | ||
649 | <?php echo (file_exists('./htmLawed_TESTCASE.txt') ? '<br /><br />You can use text from <a href="htmLawed_TESTCASE.txt"><span class="notice">this collection of test-cases</span></a> in the input. Set the character encoding of the browser to Unicode/utf-8 before copying.' : ''); ?> | 649 | <?php echo (file_exists('./htmLawed_TESTCASE.txt') ? '<br /><br />You can use text from <a href="htmLawed_TESTCASE.txt"><span class="notice">this collection of test-cases</span></a> in the input. Set the character encoding of the browser to Unicode/utf-8 before copying.' : ''); ?> |
650 | 650 | ||
651 | <br /><br />For anti-XSS tests, try the <a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/htmLawedSafeModeTest.php"><span class="notice">special test-page</span></a> or see <a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/rsnake/RSnakeXSSTest.htm"><span class="notice">these results</span></a>. | 651 | <br /><br />For anti-XSS tests, try the <a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/htmLawedSafeModeTest.php"><span class="notice">special test-page</span></a> or see <a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/rsnake/RSnakeXSSTest.htm"><span class="notice">these results</span></a>. |
652 | 652 | ||
653 | <br /><br /><small>Change <em>Encoding</em> to reflect the character encoding of the input text. Even then, it may not work or some characters may not display properly because of variable browser support and because of the form interface. Developers can write some PHP code to capture the filtered input to a file if this is important. | 653 | <br /><br /><small>Change <em>Encoding</em> to reflect the character encoding of the input text. Even then, it may not work or some characters may not display properly because of variable browser support and because of the form interface. Developers can write some PHP code to capture the filtered input to a file if this is important. |
654 | <br /><br />Refer to the htmLawed documentation (<a href="htmLawed_README.htm"><span class="notice">htm</span></a>/<a href="htmLawed_README.txt"><span class="notice">txt</span></a>) for details about <em>Settings</em>, and htmLawed's behavior and limitations. For <em>Settings</em>, incorrectly-specified values like regular expressions are silently ignored. One or more settings form-fields may have been disabled. Some characters are not allowed in the <em>Spec</em> field. | 654 | <br /><br />Refer to the htmLawed documentation (<a href="htmLawed_README.htm"><span class="notice">htm</span></a>/<a href="htmLawed_README.txt"><span class="notice">txt</span></a>) for details about <em>Settings</em>, and htmLawed's behavior and limitations. For <em>Settings</em>, incorrectly-specified values like regular expressions are silently ignored. One or more settings form-fields may have been disabled. Some characters are not allowed in the <em>Spec</em> field. |
655 | 655 | ||
656 | 656 | ||
657 | <br /><br />Hovering the mouse over some of the text can provide additional information in some browsers.</small> | 657 | <br /><br />Hovering the mouse over some of the text can provide additional information in some browsers.</small> |
658 | 658 | ||
659 | <?php | 659 | <?php |
660 | if($_w3c_validate){ | 660 | if($_w3c_validate){ |
661 | ?> | 661 | ?> |
662 | 662 | ||
663 | <small><br /><br />Because of character-encoding issues, the W3C validator (anyway not perfect) may reject validation requests or invalidate otherwise-valid code, esp. if text was copy-pasted in the input box. Local applications like the <em>HTML Validator</em> Firefox browser add-on may be useful in such cases.</small> | 663 | <small><br /><br />Because of character-encoding issues, the W3C validator (anyway not perfect) may reject validation requests or invalidate otherwise-valid code, esp. if text was copy-pasted in the input box. Local applications like the <em>HTML Validator</em> Firefox browser add-on may be useful in such cases.</small> |
664 | 664 | ||
665 | <?php | 665 | <?php |
666 | } | 666 | } |
667 | ?> | 667 | ?> |
668 | 668 | ||
669 | </div> | 669 | </div> |
670 | 670 | ||
671 | <?php | 671 | <?php |
672 | } | 672 | } |
673 | ?> | 673 | ?> |
674 | 674 | ||
675 | </div> | 675 | </div> |
676 | </body> | 676 | </body> |
677 | </html> | 677 | </html> |