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.
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.
Other file depends on this function.
Line 176 in 1a031f2
doc/api/deprecations.md
Outdated
|
|
||
| Type: Runtime | ||
|
|
||
| `tls.parseCertString()` was move to `internal/tls.js`. |
There was a problem hiding this comment.
`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.
IMHO I don't think they are equivalent since parseCertString() does no encoding or decoding.
There was a problem hiding this comment.
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.
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.
*Note*: This function is not completely equivalent to `querystring.parse()`, one notable difference...
bnoordhuis
left a comment
There was a problem hiding this comment.
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.
s/deprecate/deprecation/ and can you capitalize + punctuate the comment?
There was a problem hiding this comment.
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.
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.
@bnoordhuis, I saw a test that modified the value.
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 |
|
|
||
| *Note*: change was made while `async_hooks` was an experimental API. | ||
|
|
||
| <a id="DEP0073"></a> |
There was a problem hiding this comment.
The deprecation code should be DEP00XX until the PR lands.
There was a problem hiding this comment.
Whose job is it to replace?
There was a problem hiding this comment.
@jasnell Will be replaced when landing by the lander?
My new PR for v8.x-staging made DEP0073 to DEP00XX.
jasnell
left a comment
There was a problem hiding this comment.
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/tlsand 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