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

Url-encoded magnet links don't work #1747

Open
stopmachine opened this issue Sep 17, 2019 · 8 comments
Open

Url-encoded magnet links don't work #1747

stopmachine opened this issue Sep 17, 2019 · 8 comments
Labels

Comments

@stopmachine
Copy link

@stopmachine stopmachine commented Sep 17, 2019

What version of WebTorrent?
0.107.16

What operating system and Node.js version?
Ubuntu

What browser and version? (if using WebTorrent in the browser)
Using webtorrent-desktop, but I traced the issue to webtorrent

What did you expect to happen?
Adding a url-encoded magnet link will be decoded and will successfully start downloading

What actually happened?
Passing a url-encoded magnet link ("magnet%3A%3Fxt%3Durn%3Abtih...") fails

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Sep 18, 2019

I've never seen a magnet uri shared in this format. What is the use case here?

@feross feross added the enhancement label Sep 18, 2019
@stopmachine

This comment has been minimized.

Copy link
Author

@stopmachine stopmachine commented Sep 18, 2019

Extracting links from a web page, where the magnet links are in the query parameters part of URLs.

For example:

Torrent list

And to be a bit more specific with the use case, as I said I used webtorrent-desktop, where I tried to paste such an encoded link and got an error that it is invalid.

@guanzo

This comment has been minimized.

Copy link
Contributor

@guanzo guanzo commented Sep 18, 2019

Just decode the query parameter.

const url = new URL('https://example.com/pretty-print-magnet?link=magnet%3A%3Fxt%3Durn%3Abtih')
url.searchParams.get('link') // magnet:?xt=urn:btih
@stopmachine

This comment has been minimized.

Copy link
Author

@stopmachine stopmachine commented Sep 18, 2019

A non-technical user will have trouble doing that. As I mentioned the link is pasted into webtorrent-desktop, which passes it as-is to webtorrent. So the question is, should decoding be introduced in webtorrent-desktop or webtorrent. Making webtorrent-desktop's enduser do the decoding himself before pasting feels wrong.

@guanzo

This comment has been minimized.

Copy link
Contributor

@guanzo guanzo commented Sep 18, 2019

Sorry I didn't read the issue thoroughly. How does the end user receive the link? is it not possible for some code to decode before displaying to the user?

@stopmachine

This comment has been minimized.

Copy link
Author

@stopmachine stopmachine commented Sep 19, 2019

The end user copies it from the web page in his browser. There is no control over the web page's source. It is of course possible to write some kind of a tailored browser plug-in, but that would require plugins for Chrome and Firefox, and will not solve the problem for browsers without plugin support like IE.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Sep 19, 2019

@stopmachine Thanks for your responses, but I'm still confused a bit.

What do the example links you posted actually link to? WebTorrent would assume this is a link to a .torrent file and attempt to download it.

Or are you saying that the user would slice off the part after ?link= on their own and paste that part into WebTorrent Desktop?

Also, what do other torrent clients do in this case?

  • Transmission?
  • uTorrent?
  • qBittorrent?
@stopmachine

This comment has been minimized.

Copy link
Author

@stopmachine stopmachine commented Sep 19, 2019

Or are you saying that the user would slice off the part after ?link= on their own and paste that part into WebTorrent Desktop?

Exactly.

I've tested Transmission, it fails too when pasting a url-encoded link (it doesn't support pasting in the main window like WebTorrent Desktop does, you have to select File -> Open URL from the menu first). But I like WebTorrent Desktop because it's better, not because it's on-par :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.