Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Add some tests for upload validation and fix a related typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoisin committed Oct 23, 2017
1 parent 970d12b commit 2c42514
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sp_upload_validation.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra) {
if (WEXITSTATUS(waitstatus) != 0) { // Nope
char *uri = sp_getenv("REQUEST_URI");
int sim = SNUFFLEUPAGUS_G(config).config_upload_validation->simulation;
sp_log_msg("upload_valiation", sim?SP_LOG_SIMULATION:SP_LOG_DROP,
sp_log_msg("upload_validation", sim?SP_LOG_SIMULATION:SP_LOG_DROP,
"The upload of %s on %s was rejected.", filename, uri?uri:"?");
if (!SNUFFLEUPAGUS_G(config).config_upload_validation->simulation) {
zend_bailout();
Expand Down
2 changes: 1 addition & 1 deletion src/tests/upload_validation_invalid.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ echo 1;
?>
--EXPECTF--
[snuffleupagus][0.0.0.0][upload_validation][error] Could not call './tests/data/upload_invalid.sh' : Exec format error
[snuffleupagus][0.0.0.0][upload_valiation][drop] The upload of test.php on ? was rejected.
[snuffleupagus][0.0.0.0][upload_validation][drop] The upload of test.php on ? was rejected.
2 changes: 1 addition & 1 deletion src/tests/upload_validation_ko.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Content-Disposition: form-data; name="test"; filename="test.php"
--blabla--
--FILE--
--EXPECTF--
[snuffleupagus][0.0.0.0][upload_valiation][drop] The upload of test.php on ? was rejected.
[snuffleupagus][0.0.0.0][upload_validation][drop] The upload of test.php on ? was rejected.
15 changes: 15 additions & 0 deletions src/tests/upload_validation_ko_simulation.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Upload a file, validation ko, simulation
--INI--
file_uploads=1
sp.configuration_file={PWD}/config/upload_validation_ko_simulation.ini
output_buffering=off
--POST_RAW--
Content-Type: multipart/form-data; boundary=blabla
--blabla
Content-Disposition: form-data; name="test"; filename="test.php"
--blabla--
--FILE--
<?php echo 1337; ?>
--EXPECTF--
1337

0 comments on commit 2c42514

Please sign in to comment.