-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
tls: move parseCertString to internal #14218
tls: move parseCertString to internal #14218
Conversation
`tls.parseCertString()` exposed by accident. Now move this function to `internal/tls` and mark the original one as deprecated. Refs: nodejs#14193 Refs: nodejs@af80e7b#diff-cc32376ce1eaf679ec2298cd483f15c7R188
I think we should add a document to mark this function. Refs #14196 |
} | ||
return out; | ||
}; | ||
exports.parseCertString = internalUtil.deprecate( |
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.
IMHO there's no need to move the function, just replace the export with this deprecation-wrapped-export.
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.
Other file depends on this function.
Line 176 in 1a031f2
if (c.subject) c.subject = tls.parseCertString(c.subject); |
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.
Ack.
doc/api/deprecations.md
Outdated
|
||
Type: Runtime | ||
|
||
`tls.parseCertString()` was move to `internal/tls.js`. |
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.
`tls.parseCertString()` is a trivial parsing helper that was made public by mistake.
Can be replaced with
```js
const querystring = require('querystring');
querystring.parse(str, '\n', '=')`;
```
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.
IMHO I don't think they are equivalent since parseCertString()
does no encoding or decoding.
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.
eg.
> querystring.parse("%E5%A5%BD=1", "\n", "=");
{ '好': '1' }
> tls.parseCertString("%E5%A5%BD=1");
{ '%E5%A5%BD': '1' }
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.
I would like us to have a suggested alternative available, so maybe:
`tls.parseCertString()` is a trivial parsing helper that was made public by mistake.
This function can usually be replaced with
```js
const querystring = require('querystring');
querystring.parse(str, '\n', '=')`;
```
*Note*: One difference is that `querystring.parse` does URLDecoding, e.g.:
```js
> querystring.parse("%E5%A5%BD=1", "\n", "=");
{ '好': '1' }
> tls.parseCertString("%E5%A5%BD=1");
{ '%E5%A5%BD': '1' }
```
querystring.parse(str, '\n', '=')`; | ||
``` | ||
|
||
*Note*: This function is not 100% same as `querystring.parse()`. One difference |
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.
*Note*: This function is not completely equivalent to `querystring.parse()`, one notable difference...
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.
Can you split the commit in two? One that moves parseCertString() and another that moves the constants?
const regexp = new RegExp('^\\(node:\\d+\\) [DEP0073] DeprecationWarning: ' + | ||
'tls\\.parseCertString is deprecated$'); | ||
|
||
// test for deprecate message |
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.
s/deprecate/deprecation/ and can you capitalize + punctuate the comment?
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.
You can/should use common.expectWarning()
to check for this without having to hijack stderr
Object.defineProperty(exports, key, { | ||
get: () => { return internalTLS[key]; }, | ||
set: (c) => { internalTLS[key] = c; } | ||
}); |
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.
Defining accessors for otherwise simple data properties is kind of wasteful, just re-export the values from internal/tls.
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.
@bnoordhuis, I saw a test that modified the value.
Refs: https://github.com/nodejs/node/blob/v8.1.4/test/parallel/test-tls-honorcipherorder.js#L97
If we don't tie these two variables as getter and setter, the value may be not equivalent.
Should we be deprecating something before the next major version? Or is this not going into v8.x? |
It's in limbo since it's undocumented in so @XadillaX Could you split into 3 commits: docs + function move + constant move |
@refack Did you mean:
|
Yes, exactly (so that we could land just (1) in |
@@ -634,6 +634,29 @@ Type: Runtime | |||
|
|||
*Note*: change was made while `async_hooks` was an experimental API. | |||
|
|||
<a id="DEP0073"></a> |
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.
The deprecation code should be DEP00XX
until the PR lands.
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.
Whose job is it to replace?
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.
@jasnell Will be replaced when landing by the lander?
My new PR for v8.x-staging made DEP0073
to DEP00XX
.
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.
Test needs a bit of tweaking... otherwise it's looking good.
I think the third point should be created the PR after point 2 is landed. |
tls.parseCertString()
exposed by accident. Now move this function tointernal/tls
and mark the original one as deprecated.Refs: #14193
Refs: af80e7b#diff-cc32376ce1eaf679ec2298cd483f15c7R188
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
tls