Skip to content
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

Closed

Conversation

XadillaX
Copy link
Contributor

@XadillaX XadillaX commented Jul 13, 2017

tls.parseCertString() exposed by accident. Now move this function to
internal/tls and mark the original one as deprecated.

Refs: #14193
Refs: af80e7b#diff-cc32376ce1eaf679ec2298cd483f15c7R188

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

tls

`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
@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. tls Issues and PRs related to the tls subsystem. labels Jul 13, 2017
@XadillaX
Copy link
Contributor Author

I think we should add a document to mark this function. Refs #14196

@XadillaX XadillaX mentioned this pull request Jul 13, 2017
2 tasks
}
return out;
};
exports.parseCertString = internalUtil.deprecate(
Copy link
Contributor

@refack refack Jul 13, 2017

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.

Copy link
Contributor Author

@XadillaX XadillaX Jul 13, 2017

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.

if (c.subject) c.subject = tls.parseCertString(c.subject);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.


Type: Runtime

`tls.parseCertString()` was move to `internal/tls.js`.
Copy link
Contributor

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', '=')`;
```

Copy link
Contributor Author

@XadillaX XadillaX Jul 13, 2017

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.

Copy link
Contributor Author

@XadillaX XadillaX Jul 13, 2017

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' }

Copy link
Contributor

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
Copy link
Contributor

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...

Copy link
Member

@bnoordhuis bnoordhuis left a 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
Copy link
Member

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?

Copy link
Member

@jasnell jasnell Jul 14, 2017

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; }
});
Copy link
Member

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.

Copy link
Contributor Author

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.

@mscdex
Copy link
Contributor

mscdex commented Jul 13, 2017

Should we be deprecating something before the next major version? Or is this not going into v8.x?

@refack
Copy link
Contributor

refack commented Jul 13, 2017

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 v8 so in theory could be just doc-deprecated.
/cc @nodejs/release

so @XadillaX Could you split into 3 commits: docs + function move + constant move

@XadillaX
Copy link
Contributor Author

@refack Did you mean:

  1. mark the function as deprecated with documented-only
  2. move the function and modify the document with runtime
  3. move the constant

@refack
Copy link
Contributor

refack commented Jul 14, 2017

@refack Did you mean:

mark the function as deprecated with documented-only
move the function and modify the document with runtime
move the constant

Yes, exactly (so that we could land just (1) in v8.x)

@@ -634,6 +634,29 @@ Type: Runtime

*Note*: change was made while `async_hooks` was an experimental API.

<a id="DEP0073"></a>
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@XadillaX XadillaX Jul 15, 2017

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.

Copy link
Member

@jasnell jasnell left a 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.

@XadillaX
Copy link
Contributor Author

@refack Did you mean:

  1. mark the function as deprecated with documented-only
  2. move the function and modify the document with runtime
  3. move the constant

Yes, exactly (so that we could land just (1) in v8.x)

I think the third point should be created the PR after point 2 is landed.

@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Jul 18, 2017
@XadillaX XadillaX closed this Jul 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. semver-minor PRs that contain new features and should be released in the next minor version. tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants