Skip to content

Commit dbaa56d

Browse files
committedSep 28, 2015
Updated test and html encoding-decoding code (didn't really work as expected)
1 parent 1dbc0d0 commit dbaa56d

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed
 

‎Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function main($request, $compiler_config)
7171
* Decode any HTML entities found in project/libraries files
7272
*/
7373
$request['files'] = $this->utility->htmlDecodeFiles($request['files']);
74-
$request['libraries'] = $this->utility->htmlDecodeLibraries($request['libraries']);
74+
$libraries = $this->utility->htmlDecodeLibraries($libraries);
7575

7676
// Step 1(part 1): Extract the project files included in the request.
7777
$files = array();

‎Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,9 @@ function htmlDecodeFiles($files)
157157
return array();
158158
}
159159

160-
$htmlDecodedFiles = array();
161-
foreach ($files as $file) {
162-
$htmlDecodedFiles[] = array(
163-
'filename' => $file['filename'],
164-
'content' => htmlspecialchars_decode($file['content'])
165-
);
166-
}
167-
return $htmlDecodedFiles;
160+
array_walk($files, function(&$item){$item['content'] = htmlspecialchars_decode($item['content']);});
161+
162+
return $files;
168163
}
169164

170165
/**

‎Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public function testEthernetCompileErrorRemovedLibraryPaths()
254254
$files = array(array("filename" => "Blink.ino", "content" => "#include <Ethernet.h>\nvoid setup() {\n}\nvoid loop() {\n}\n"));
255255
$format = "binary";
256256
$version = "105";
257-
$libraries = array('PseudoEthernet' => array('files' => array('filename' => 'Ethernet.h', 'content' => "#include \"SPI.h\"\n")));
257+
$libraries = array('PseudoEthernet' => array(0 => array('filename' => 'Ethernet.h', 'content' => "#include \"SPI.h\"\n")));
258258
$build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard");
259259

260260
$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));
@@ -277,7 +277,7 @@ public function testEthernetCompileErrorRemovedPersonalLibraryPaths()
277277
$files = array(array("filename" => "Blink.ino", "content" => "#include <Ethernet.h>\nvoid setup() {\n}\nvoid loop() {\n}\n"));
278278
$format = "binary";
279279
$version = "105";
280-
$libraries = array('4096_cb_personal_lib_PseudoEthernet' => array('files' => array('filename' => 'Ethernet.h', 'content' => "#include \"SPI.h\"\n")));
280+
$libraries = array('4096_cb_personal_lib_PseudoEthernet' => array(0 => array('filename' => 'Ethernet.h', 'content' => "#include \"SPI.h\"\n")));
281281
$build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard");
282282

283283
$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));
@@ -300,7 +300,7 @@ public function testHtmlEncodedInput()
300300
$files = array(array("filename" => "Blink.ino", "content" => htmlspecialchars("#include <Ethernet.h>\nint * pointer;\nvoid setup() {\nint ** var = &pointer;\n}\nvoid loop() {\n}\n")));
301301
$format = "binary";
302302
$version = "105";
303-
$libraries = array('Ethernet' => array('files' => array('filename' => 'Ethernet.h', 'content' => htmlspecialchars("\n"))));
303+
$libraries = array('Ethernet' => array(0 => array('filename' => 'Ethernet.h', 'content' => htmlspecialchars('#include "Arduino.h"'))));
304304
$build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard");
305305

306306
$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));

0 commit comments

Comments
 (0)
Please sign in to comment.