tool_operate: make --doh-url "" switch it off#9207
Closed
Conversation
Member
|
I'm skeptical about doing this with strings because we may have logic elsewhere that needs to be addressed (as is the case here, see the squashme for env logic) and that can lead to bugs. An alternative would be handle it during parsing, diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 9bbd51d..0aec45d 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -700,7 +700,10 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
return err;
break;
case 'C': /* doh-url */
- GetStr(&config->doh_url, nextarg);
+ if(nextarg && *nextarg)
+ GetStr(&config->doh_url, nextarg);
+ else /* this option is documented as unset by an empty string */
+ Curl_safefree(config->doh_url);
break;
case 'd': /* ciphers */
GetStr(&config->cipher_list, nextarg); |
A possible future addition could be to parse the URL first too to verify that it is valid before trying to use it. Assisted-by: Jay Satiro Closes #9207
6a96c42 to
1b5fbb0
Compare
Member
Author
|
Yeah, setting it to NULL again is clearly a better approach. |
jay
approved these changes
Jul 27, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A possible future addition could be to parse the URL first too to verify
that it is valid before trying to use it.