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

Sanitize only special URLs #209

Merged
merged 1 commit into from Jul 25, 2021
Merged

Sanitize only special URLs #209

merged 1 commit into from Jul 25, 2021

Conversation

lpinca
Copy link
Member

@lpinca lpinca commented Jul 25, 2021

@lpinca lpinca requested a review from 3rd-Eden July 25, 2021 08:20
@3rd-Eden 3rd-Eden merged commit 2d9ac2c into master Jul 25, 2021
@lpinca lpinca deleted the skip/sanitization branch July 25, 2021 13:06
@enahum
Copy link

enahum commented Jul 25, 2021

this is causing issues. let's say I have a path file:://file-path/file.png after parsing the href prop is returning file:///file-path/file.png notice the third slash after the protocol.

@lpinca
Copy link
Member Author

lpinca commented Jul 25, 2021

@enahum I see that the Node.js URL parser handles this differently

new URL('file://file-path/file')
URL {
  href: 'file://file-path/file',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: 'file-path',
  hostname: 'file-path',
  port: '',
  pathname: '/file',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}

but the issue it not caused by this commit. This behavior was introduced with d2979b5. I'll see if I can fix it.

@lpinca
Copy link
Member Author

lpinca commented Jul 25, 2021

Anyway this is kind of funny:

> new URL('file:file-path/file')
URL {
  href: 'file:///file-path/file',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: '',
  hostname: '',
  port: '',
  pathname: '/file-path/file',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}
> new URL('file:/file-path/file')
URL {
  href: 'file:///file-path/file',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: '',
  hostname: '',
  port: '',
  pathname: '/file-path/file',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}
> new URL('file://file-path/file')
URL {
  href: 'file://file-path/file',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: 'file-path',
  hostname: 'file-path',
  port: '',
  pathname: '/file',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}
> new URL('file:///file-path/file')
URL {
  href: 'file:///file-path/file',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: '',
  hostname: '',
  port: '',
  pathname: '/file-path/file',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}

I wonder if a file: url can have a host.

lpinca added a commit that referenced this pull request Jul 25, 2021
@lpinca
Copy link
Member Author

lpinca commented Jul 25, 2021

@enahum #210 should fix the issue.

3rd-Eden pushed a commit that referenced this pull request Jul 25, 2021
@3rd-Eden
Copy link
Member

Published as 1.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants