File: phpt-modifications.patch

package info (click to toggle)
php-htmlpurifier 4.1.1%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 4,556 kB
  • ctags: 6,547
  • sloc: php: 26,336; xml: 1,630; makefile: 70; sh: 14
file content (367 lines) | stat: -rw-r--r-- 12,910 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
Index: src/PHPT/Case.php
===================================================================
--- src/PHPT/Case.php	(revision 691)
+++ src/PHPT/Case.php	(working copy)
@@ -28,17 +28,14 @@
     {
         $reporter->onCaseStart($this);
         try {
-            if ($this->sections->filterByInterface('RunnableBefore')->valid()) {
-                foreach ($this->sections as $section) {
-                    $section->run($this);
-                }
+            $runnable_before = $this->sections->filterByInterface('RunnableBefore');
+            foreach ($runnable_before as $section) {
+                $section->run($this);
             }
-            $this->sections->filterByInterface();
             $this->sections->FILE->run($this);
-            if ($this->sections->filterByInterface('RunnableAfter')->valid()) {
-                foreach ($this->sections as $section) {
-                    $section->run($this);
-                }
+            $runnable_after = $this->sections->filterByInterface('RunnableAfter');
+            foreach ($runnable_after as $section) {
+                $section->run($this);
             }
             $reporter->onCasePass($this);
         } catch (PHPT_Case_VetoException $veto) {
@@ -46,7 +43,6 @@
         } catch (PHPT_Case_FailureException $failure) {
             $reporter->onCaseFail($this, $failure);
         }
-        $this->sections->filterByInterface();
         $reporter->onCaseEnd($this);
     }
     
Index: src/PHPT/Case/Validator/CgiRequired.php
===================================================================
--- src/PHPT/Case/Validator/CgiRequired.php	(revision 691)
+++ src/PHPT/Case/Validator/CgiRequired.php	(working copy)
@@ -17,7 +17,6 @@
     public function is(PHPT_Case $case)
     {
         $return = $case->sections->filterByInterface('CgiExecutable')->valid();
-        $case->sections->filterByInterface();
         return $return;
     }
 }
Index: src/PHPT/CodeRunner/CommandLine.php
===================================================================
--- src/PHPT/CodeRunner/CommandLine.php	(revision 691)
+++ src/PHPT/CodeRunner/CommandLine.php	(working copy)
@@ -13,7 +13,7 @@
         $this->_filename = $runner->filename;
         $this->_ini = (string)$runner->ini;
         $this->_args = (string)$runner->args;
-        $this->_executable = str_replace(' ', '\ ', (string)$runner->executable);
+        $this->_executable = $runner->executable;
         $this->_post_filename = (string)$runner->post_filename;
     }
     
Index: src/PHPT/CodeRunner/Driver/WScriptShell.php
===================================================================
--- src/PHPT/CodeRunner/Driver/WScriptShell.php	(revision 691)
+++ src/PHPT/CodeRunner/Driver/WScriptShell.php	(working copy)
@@ -23,9 +23,9 @@
             }
         }
         if ($found == false) {
-            throw new PHPT_CodeRunner_InvalidExecutableException(
-                'unable to locate PHP executable: ' . $this->executable
-            );
+            //throw new PHPT_CodeRunner_InvalidExecutableException(
+            //    'unable to locate PHP executable: ' . $this->executable
+            //);
         }
     }
 
@@ -69,7 +69,7 @@
 
         $error = $this->_process->StdErr->ReadAll();
         if (!empty($error)) {
-            throw new PHPT_CodeRunner_ExecutionException($error);
+            throw new PHPT_CodeRunner_ExecutionException($error, $this->_commandFactory());
         }
 
         return $this->_process->StdOut->ReadAll();
@@ -93,6 +93,7 @@
     {
         $return = '';
         foreach ($this->environment as $key => $value) {
+            $value = str_replace('&', '^&', $value);
             $return .= "set {$key}={$value} & ";
         }
         return $return;
Index: src/PHPT/CodeRunner/Factory.php
===================================================================
--- src/PHPT/CodeRunner/Factory.php	(revision 691)
+++ src/PHPT/CodeRunner/Factory.php	(working copy)
@@ -33,7 +33,13 @@
                 'php-cgi';
         }
 
-        if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+        if (
+            strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' &&
+            (
+                $runner->executable == 'php' ||
+                $runner->executable == 'php-cgi'
+            )
+        ) {
             $runner->executable = $runner->executable . '.exe';
         }
         try {
Index: src/PHPT/Section/ModifiableAbstract.php
===================================================================
--- src/PHPT/Section/ModifiableAbstract.php	(revision 691)
+++ src/PHPT/Section/ModifiableAbstract.php	(working copy)
@@ -15,12 +15,10 @@
     
     public function run(PHPT_Case $case)
     {
-        $sections = clone $case->sections;
-        if ($sections->filterByInterface($this->_modifier_name . 'Modifier')->valid()) {
-            $modifyMethod = 'modify' . $this->_modifier_name;
-            foreach ($sections as $section) {
-                $section->$modifyMethod($this);
-            }
+        $modifiers = $case->sections->filterByInterface($this->_modifier_name . 'Modifier');
+        $modifyMethod = 'modify' . $this->_modifier_name;
+        foreach ($modifiers as $section) {
+            $section->$modifyMethod($this);
         }
     }
     
Index: src/PHPT/Section/SKIPIF.php
===================================================================
--- src/PHPT/Section/SKIPIF.php	(revision 691)
+++ src/PHPT/Section/SKIPIF.php	(working copy)
@@ -3,10 +3,12 @@
 class PHPT_Section_SKIPIF implements PHPT_Section_RunnableBefore
 {
     private $_data = null;
+    private $_runner_factory = null;
     
     public function __construct($data)
     {
         $this->_data = $data;
+        $this->_runner_factory = new PHPT_CodeRunner_Factory();
     }
     
     public function run(PHPT_Case $case)
@@ -16,9 +18,7 @@
         
         // @todo refactor to PHPT_CodeRunner
         file_put_contents($filename, $this->_data);
-        $response = array();
-        exec('php -f ' . $filename, $response);
-        $response = implode("\n", $response);
+        $response = $this->_runner_factory->factory($case)->run($filename)->output;
         unlink($filename);
         
         if (preg_match('/^skip( - (.*))?/', $response, $matches)) {
Index: src/PHPT/SectionList.php
===================================================================
--- src/PHPT/SectionList.php	(revision 691)
+++ src/PHPT/SectionList.php	(working copy)
@@ -2,7 +2,6 @@
 
 class PHPT_SectionList implements Iterator
 {
-    private $_raw_sections = array();
     private $_sections = array();
     private $_section_map = array();
     private $_key_map = array();
@@ -15,14 +14,12 @@
             }
             $name = strtoupper(str_replace('PHPT_Section_', '', get_class($section)));
             $key = $section instanceof PHPT_Section_Runnable ? $section->getPriority() . '.' . $name : $name;
-            $this->_raw_sections[$key] = $section;
+            $this->_sections[$key] = $section;
             $this->_section_map[$name] = $key;
             $this->_key_map[$key] = $name;
         }
         
-        ksort($this->_raw_sections);
-        
-        $this->_sections = $this->_raw_sections;
+        ksort($this->_sections);
     }
     
     public function current()
@@ -52,21 +49,23 @@
     
     public function filterByInterface($interface = null)
     {
+        $ret = new PHPT_SectionList();
+        
         if (is_null($interface)) {
-            $this->_sections = $this->_raw_sections;
-            return $this;
+            $ret->_sections = $this->_sections;
+            return $ret;
         }
         
         $full_interface = 'PHPT_Section_' . $interface;
-        $this->_sections = array();
-        foreach ($this->_raw_sections as $name => $section) {
+        $ret->_sections = array();
+        foreach ($this->_sections as $name => $section) {
             if (!$section instanceof $full_interface) {
                 continue;
             }
-            $this->_sections[$name] = $section;
+            $ret->_sections[$name] = $section;
         }
         
-        return $this;
+        return $ret;
     }
     
     public function has($name)
@@ -74,11 +73,11 @@
         if (!isset($this->_section_map[$name])) {
             return false;
         }
-        return isset($this->_raw_sections[$this->_section_map[$name]]);
+        return isset($this->_sections[$this->_section_map[$name]]);
     }
     
     public function __get($key)
     {
-        return $this->_raw_sections[$this->_section_map[$key]];
+        return $this->_sections[$this->_section_map[$key]];
     }
 }
Index: tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt
===================================================================
--- tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt	(revision 691)
+++ tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt	(working copy)
@@ -17,9 +17,9 @@
 
 // sanity check
 $obj = new FoobarIni();
-assert('(string)$obj == " -d display_errors=1 "');
+assert('(string)$obj == " -d \"display_errors=1\" "');
 $obj->display_errors = 0;
-assert('(string)$obj == " -d display_errors=0 "');
+assert('(string)$obj == " -d \"display_errors=0\" "');
 unset($obj);
 
 
Index: tests/Section/File/restores-case-sections.phpt
===================================================================
--- tests/Section/File/restores-case-sections.phpt	(revision 691)
+++ tests/Section/File/restores-case-sections.phpt	(working copy)
@@ -1,24 +0,0 @@
---TEST--
-After PHPT_Section_FILE::run(), the sections property of the provide $case object
-is restored to its unfiltered state
---FILE--
-<?php
-
-require_once dirname(__FILE__) . '/../../_setup.inc';
-require_once dirname(__FILE__) . '/../_simple-test-case.inc';
-require_once dirname(__FILE__) . '/_simple-file-modifier.inc';
-
-$case = new PHPT_SimpleTestCase();
-$case->sections = new PHPT_SectionList(array(
-    new PHPT_Section_ARGS('foo=bar'),
-));
-
-$section = new PHPT_Section_FILE('hello world');
-$section->run($case);
-
-assert('$case->sections->valid()');
-
-?>
-===DONE===
---EXPECT--
-===DONE===
Index: tests/SectionList/filter-by-interface.phpt
===================================================================
--- tests/SectionList/filter-by-interface.phpt	(revision 691)
+++ tests/SectionList/filter-by-interface.phpt	(working copy)
@@ -17,10 +17,10 @@
 
 $data = array_merge($runnable, $non_runnable);
 $list = new PHPT_SectionList($data);
-$list->filterByInterface('Runnable');
-assert('$list->valid()');
-$list->filterByInterface('EnvModifier');
-assert('$list->valid() == false');
+$runnable = $list->filterByInterface('Runnable');
+assert('$runnable->valid()');
+$env_modifier = $list->filterByInterface('EnvModifier');
+assert('$env_modifier->valid() == false');
 
 ?>
 ===DONE===
Index: tests/SectionList/filter-resets-with-null.phpt
===================================================================
--- tests/SectionList/filter-resets-with-null.phpt	(revision 691)
+++ tests/SectionList/filter-resets-with-null.phpt	(working copy)
@@ -1,36 +0,0 @@
---TEST--
-If you call filterByInterface() with null or no-value, the full dataset is restored
---FILE--
-<?php
-
-require_once dirname(__FILE__) . '/../_setup.inc';
-
-$runnable = array(
-    'ENV' => new PHPT_Section_ENV(''),
-    'CLEAN' => new PHPT_Section_CLEAN(''),
-);
-
-class PHPT_Section_FOO implements PHPT_Section { }
-$non_runnable = array(
-    'FOO' => new PHPT_Section_FOO(), 
-);
-
-$data = array_merge($runnable, $non_runnable);
-$list = new PHPT_SectionList($data);
-$list->filterByInterface('Runnable');
-
-// sanity check
-foreach ($list as $key => $value) {
-    assert('$runnable[$key] == $value');
-}
-
-$list->filterByInterface();
-
-foreach ($list as $key => $value) {
-    assert('$data[$key] == $value');
-}
-
-?>
-===DONE===
---EXPECT--
-===DONE===
Index: tests/Util/Code/runAsFile-executes-in-file.phpt
===================================================================
--- tests/Util/Code/runAsFile-executes-in-file.phpt	(revision 691)
+++ tests/Util/Code/runAsFile-executes-in-file.phpt	(working copy)
@@ -10,7 +10,7 @@
 
 $util = new PHPT_Util_Code($code);
 
-$file = dirname(__FILE__) . '/foobar.php';
+$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foobar.php';
 $result = $util->runAsFile($file);
 
 assert('$result == $file');
Index: tests/Util/Code/runAsFile-returns-output-if-no-return.phpt
===================================================================
--- tests/Util/Code/runAsFile-returns-output-if-no-return.phpt	(revision 691)
+++ tests/Util/Code/runAsFile-returns-output-if-no-return.phpt	(working copy)
@@ -9,7 +9,7 @@
 
 $util = new PHPT_Util_Code($code);
 
-$file = dirname(__FILE__) . '/foobar.php';
+$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foobar.php';
 $result = $util->runAsFile($file);
 
 assert('$result == $file');