-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[RFC] FILTER_THROW_ON_FAILURE #18896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
|
||
#define FILTER_FORCE_ARRAY 0x4000000 | ||
#define FILTER_NULL_ON_FAILURE 0x8000000 | ||
#define FILTER_THROW_ON_FAILURE 0x10000000 | ||
|
||
#define FILTER_FLAG_ALLOW_OCTAL 0x0001 | ||
#define FILTER_FLAG_ALLOW_HEX 0x0002 | ||
|
@@ -50,7 +51,7 @@ | |
#define FILTER_FLAG_IPV6 0x00200000 | ||
#define FILTER_FLAG_NO_RES_RANGE 0x00400000 | ||
#define FILTER_FLAG_NO_PRIV_RANGE 0x00800000 | ||
#define FILTER_FLAG_GLOBAL_RANGE 0x10000000 | ||
#define FILTER_FLAG_GLOBAL_RANGE 0x20000000 | ||
|
||
#define FILTER_FLAG_HOSTNAME 0x100000 | ||
|
||
|
@@ -93,17 +94,26 @@ | |
|| (id >= FILTER_VALIDATE_ALL && id <= FILTER_VALIDATE_LAST) \ | ||
|| id == FILTER_CALLBACK) | ||
|
||
|
||
/* When using FILTER_THROW_ON_FAILURE, we can't actually throw the error here | ||
* because we don't have access to the name of the filter. Returning FAILURE | ||
* from the filter handler indicates that validation failed *and* an exception | ||
* should thus be thrown. */ | ||
#define RETURN_VALIDATION_FAILED \ | ||
if (EG(exception)) { \ | ||
return; \ | ||
return SUCCESS; \ | ||
This comment was marked as resolved.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this should be success, because success here means that we shouldn't create a new exception for the filter failure |
||
} else if (flags & FILTER_THROW_ON_FAILURE) { \ | ||
zval_ptr_dtor(value); \ | ||
ZVAL_NULL(value); \ | ||
return FAILURE; \ | ||
} else if (flags & FILTER_NULL_ON_FAILURE) { \ | ||
zval_ptr_dtor(value); \ | ||
ZVAL_NULL(value); \ | ||
} else { \ | ||
zval_ptr_dtor(value); \ | ||
ZVAL_FALSE(value); \ | ||
} \ | ||
return; \ | ||
return SUCCESS; \ | ||
|
||
#define PHP_FILTER_TRIM_DEFAULT(p, len) PHP_FILTER_TRIM_DEFAULT_EX(p, len, 1); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.