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

Fix sslcapath bug #636

Merged
merged 3 commits into from
Jan 18, 2018
Merged

Fix sslcapath bug #636

merged 3 commits into from
Jan 18, 2018

Conversation

LaysDragon
Copy link
Contributor

#634 Thanks for your suggestion I finally split two pull request.
@SISheogorath

@SISheogorath
Copy link
Contributor

Well, I said moving the code, so we can remove the validation in the app.js since we already do the config validation in the config module.

No need to validate it twice.

@SISheogorath SISheogorath added bug Something isn't working untested This has not be verified to be working labels Nov 28, 2017
@LaysDragon
Copy link
Contributor Author

LaysDragon commented Nov 29, 2017

But what the code does is not validation ,it is reading each file from path just like other ssl option.
https://github.com/hackmdio/hackmd/blob/c794412714cdd7b0f6ebfadaf108f72098004d64/app.js#L49-L56
https://github.com/hackmdio/hackmd/blob/c794412714cdd7b0f6ebfadaf108f72098004d64/app.js#L58-L61
It shouldn't be removed from app.js.

@SISheogorath
Copy link
Contributor

Yes, you are right, I misread it. Thanks for pointing me to this ^^

var i, len, results
results = []
for (i = 0, len = config.sslcapath.length; i < len; i++) {
results.push(path.join(appRootPath, config.sslcapath[i]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use path.resolve() instead of path.join.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why don't we replace other path.join() in index.js into path.resolve()?

Copy link
Contributor

@SISheogorath SISheogorath Dec 4, 2017

Choose a reason for hiding this comment

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

We'll do this while refactoring, but right now we touch this part of the code and we should use resolve() since it doesn't break absolute paths. :)

But it should be changed to resolve() for the other paths as well.

Copy link
Contributor Author

@LaysDragon LaysDragon Dec 4, 2017

Choose a reason for hiding this comment

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

I just curious is there any good reason to use resolve () instead of join ()? As I know they seems to do the same thing here.

path.join(appRootPath, config.sslcapath[i])
path.resolve(appRootPath, config.sslcapath[i])

Copy link
Contributor

Choose a reason for hiding this comment

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

While join will simply append the added path, resolve does always return an absolute path to the file. And it can handle absolute path as input, which join doesn't.

so when you put path.join("/opt/hackmd", "/tmp/somefile") you'll get /opt/hackmd/tmp/somefile while path.resolve("/opt/hackmd", "/tmp/somefile") returns /tmp/somefile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh well.I got it.I just wondered why we'll need put two absolute path as parameter,that really weird since it isn't necessary.
Because if I specified an absolute path in config,the join() can't handle it as expected,right?:)

Copy link
Contributor

Choose a reason for hiding this comment

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

resolve takes absolute paths as well as relatives, but always returns an absolute one.

As mentioned before: path.resolve("/opt/hackmd", "/tmp/somefile") returns /tmp/somefile.
But also possible: path.resolve("/opt/hackmd", "config/somefile") returns /opt/hackmd/config/somefile.

So resolve does both, while join can only handle relative paths.

Copy link
Contributor

@SISheogorath SISheogorath left a comment

Choose a reason for hiding this comment

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

Needs a test, but basically approved

@SISheogorath
Copy link
Contributor

Can you please rebase this to the latest master?


How to do this?

  1. Check what remotes exist: git remote -v
  2. If upstream doesn't exist, add it: git remote add upstream https://github.com/hackmdio/hackmd.git
  3. Stash your WIP: git stash
  4. Checkout master: git checkout master
  5. Pull latest changes from upstream: git pull upstream master
  6. Checkout the branch you worked on before: git checkout <your branch>
  7. Rebase to new master branch: git rebase master
  8. Resolve conflicts if they appear
  9. Get your changes back: git stash pop

@LaysDragon
Copy link
Contributor Author

wow,thanks for the tips,I don't know I can do this with git. XD

@SISheogorath SISheogorath merged commit 8375544 into hackmdio:master Jan 18, 2018
@SISheogorath SISheogorath mentioned this pull request Jan 18, 2018
edgarogh pushed a commit to WartaPoirier-corp/codimd that referenced this pull request Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untested This has not be verified to be working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants