-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix: handle trigger correctly #59
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| #include "lib_private.h" | ||
|
|
||
| #include "log.h" | ||
|
|
||
| extern ZEND_DECLARE_MODULE_GLOBALS(xdebug); | ||
|
|
||
| static int xdebug_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s); | ||
|
|
@@ -46,6 +48,7 @@ static int xdebug_header_handler(sapi_header_struct *h, sapi_header_op_enum op, | |
| if (XG_LIB(headers)) { | ||
| switch (op) { | ||
| case SAPI_HEADER_ADD: | ||
| xdebug_log(XLOG_CHAN_DEBUG, XLOG_DEBUG, "Adding header '%s'.", h->header); | ||
|
Collaborator
Author
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. Since the |
||
| xdebug_llist_insert_next(XG_LIB(headers), XDEBUG_LLIST_TAIL(XG_LIB(headers)), xdstrdup(h->header)); | ||
| break; | ||
| case SAPI_HEADER_REPLACE: { | ||
|
|
@@ -59,6 +62,7 @@ static int xdebug_header_handler(sapi_header_struct *h, sapi_header_op_enum op, | |
| *colon_offset = save; | ||
| } | ||
|
|
||
| xdebug_log(XLOG_CHAN_DEBUG, XLOG_DEBUG, "Adding header '%s'.", h->header); | ||
| xdebug_llist_insert_next(XG_LIB(headers), XDEBUG_LLIST_TAIL(XG_LIB(headers)), xdstrdup(h->header)); | ||
| } break; | ||
| case SAPI_HEADER_DELETE_ALL: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,25 +4,23 @@ Test for bug #1782: Make sure we use SameSite=Lax cookies (>= PHP 7.3) | |
| <?php | ||
| require __DIR__ . '/../utils.inc'; | ||
| check_reqs('PHP >= 7.3'); | ||
| if (is_stripped_debugger()) die('skip Needs develop mode'); | ||
| ?> | ||
| --ENV-- | ||
| XDEBUG_CONFIG=idekey=testing | ||
| --INI-- | ||
| xdebug.mode=debug,develop | ||
| xdebug.mode=debug | ||
| default_charset=utf-8 | ||
| xdebug.filename_format= | ||
| xdebug.client_port=9172 | ||
| xdebug.log= | ||
| xdebug.log={TMPFILE:bug01782.txt} | ||
| xdebug.log_level=10 | ||
| --FILE-- | ||
| <?php | ||
| var_dump( xdebug_get_headers( ) ); | ||
| require_once __DIR__ . '/../utils.inc'; | ||
|
Collaborator
Author
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. Instead of using the |
||
|
|
||
| echo file_get_contents(getTmpFile('bug01782.txt')); | ||
| unlink(getTmpFile('bug01782.txt')); | ||
| ?> | ||
| --EXPECTF-- | ||
| Xdebug: [Step Debug] %sTried: localhost:9172 (through xdebug.client_host/xdebug.client_port). | ||
| %sbug01782.php:2: | ||
| array(1) { | ||
| [0] => | ||
| string(%d) "Set-Cookie: XDEBUG_SESSION=testing; path=/; SameSite=Lax" | ||
| } | ||
| %A Adding header 'Set-Cookie: XDEBUG_SESSION=testing; path=/; SameSite=Lax'. | ||
| %A | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| --TEST-- | ||
| Starting Debugger: trigger with shared secret, XDEBUG_SESSION_START | ||
| --XFAIL-- | ||
| Phase 2 early connect attempts TCP connection at RINIT before the shared secret (xdebug.trigger_value) is validated. The connection succeeds even when the trigger value does not match the secret. Original Xdebug validated the trigger value before connecting. | ||
| --ENV-- | ||
| XDEBUG_SESSION_START=foobar | ||
| --FILE-- | ||
|
|
@@ -20,7 +18,6 @@ dbgpRunFile( | |
| 'variables_order' => 'PGCS', | ||
| 'xdebug.log' => $xdebugLogFileName, 'xdebug.log_level' => 10, | ||
| 'xdebug.control_socket' => 'off', 'xdebug.path_mapping' => 'off', | ||
| 'xdebug.on_demand_debugging_enabled' => 1 | ||
|
Collaborator
Author
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. This is actually not needed for this test, once we fix the issue, it works fine even without this setting |
||
| ], | ||
| ['timeout' => 1] | ||
| ); | ||
|
|
@@ -35,9 +32,9 @@ Hi! | |
|
|
||
|
|
||
| [%d] Log opened at %s | ||
| [%d] [Step Debug] DEBUG: Found 'XDEBUG_SESSION_START' ENV variable, with value 'foobar' | ||
| [%d] [Step Debug] INFO: Not activating through legacy method because xdebug.trigger_value is set | ||
| [%d] [Config] DEBUG: Checking if trigger 'XDEBUG_TRIGGER' is enabled | ||
| [%d] [Config] INFO: Trigger value for 'XDEBUG_TRIGGER' not found, falling back to 'XDEBUG_SESSION' | ||
| [%d] [Config] INFO: Trigger value for 'XDEBUG_SESSION' not found, so not activating | ||
| [%d] [Config] INFO: Trigger value for 'PHP_DEBUGGER_SESSION' not found, so not activating | ||
| [%d] [Step Debug] DEBUG: Adding header 'Content-type: %s'. | ||
| [%d] Log closed at %s | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have already tried to connect and found out that we are not connected, we don't need to try here again