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

[Bug] Doesn't Import External PDF if URL Contains One of " \ / < > : | ? #334

Closed
alteredorange opened this issue Jan 3, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@alteredorange
Copy link

Steps to reproduce

  1. Go to https://scholarsarchive.byu.edu/cgi/viewcontent.cgi?article=4092&context=byusq
  2. Try to import his pdf into obsidian as an external pdf.
  3. Dragging or using the bookmarklet function doesn't work.

Expected behavior

The PDF is imported as an external PDF.

Actual behavior

Nothing happens. It seems the plugin doesn't recognize PDFs unless there is a .pdf in the URL.

Screen recordings or screenshots

See below.

Obsidian debug info

N/A

PDF++ debug info

N/A

Error messages

image
Actually form the error message, it might be because the url has "?article", not necessarily that it doesn't have .pdf?

@alteredorange alteredorange added the bug Something isn't working label Jan 3, 2025
@alteredorange
Copy link
Author

Ah definitely looks like the url containing "?article" is the problem, because If I just create a .pdf file file named "test", and then put the url into the file, it works fine. Perhaps there can be an option so when Bookmarking you can choose a name, or have it default to "new clip" or whatever.

@RyotaUshio
Copy link
Owner

@alteredorange

For drag-drop: you can use this option to customize what URL will be recognized as PDF. For example, .* means every URL should be considered as PDF.

obsidian://pdf-plus?setting=externalURIPatterns
Untitled

For bookmarklet: I think the bookmarklet needs to be updated so that the "?article" part will be properly encoded.

@alteredorange
Copy link
Author

alteredorange commented Jan 3, 2025

@RyotaUshio it also fails when drag and dropping. The main issue is trying to name the file part of the url, because the url contains "?" which obsidian doesn't allow in a filename (i.e. "Library/Inbox/viewcontent.cgi?article=358.pdf"). So even when I drag and drop, I get the same error:
image

@alteredorange alteredorange changed the title [Bug] Doesn't Import External PDF if .pdf not found in URL [Bug] Doesn't Import External PDF if URL One of " \ / < > : | ? Jan 3, 2025
@alteredorange alteredorange changed the title [Bug] Doesn't Import External PDF if URL One of " \ / < > : | ? [Bug] Doesn't Import External PDF if URL Contains One of " \ / < > : | ? Jan 3, 2025
@RyotaUshio
Copy link
Owner

RyotaUshio commented Jan 3, 2025

The bookmarklet on the documentation website has been updated.

As for drag-drop: as you said "?" is forbidden, you are likely to be on Windows, right? https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names

I'm on mac so I didn't notice "?" in a file name was the problem. (This is why you have to fill in the Obsidian debug info section you ignored!)

I will add some logic to sanitize file names.

@RyotaUshio
Copy link
Owner

Will be fixed in 0.40.22

@alteredorange
Copy link
Author

@RyotaUshio Windows strikes again! Thanks, sorry for the lack of debug info! And thanks for the awesome plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants