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

browser.links() should return an empty list if self.page is None #410

Open
npetrangelo opened this issue Nov 29, 2022 · 1 comment
Open

Comments

@npetrangelo
Copy link

I was writing a fuzzer for a cybersecurity assignment, and it crashed when it tried to find the links on a PDF file. I think it would make more sense to return that there are no links, if the page fails to parse. This seems relatively straightforward to implement.

@npetrangelo npetrangelo changed the title links() should return an empty list if self.page is None browser.links() should return an empty list if self.page is None Nov 29, 2022
@hemberger
Copy link
Contributor

Thanks for the suggestion! However, I think it might be misleading to have StatefulBrowser.links return an empty list if no page is currently loaded. It's a very different case than having a page with no links. Can you elaborate a bit more on the use case? Would the following be useful in your application?

links = [] if br.page is None else br.links()

At the very least, we could improve the error message when you call StatefulBrowser.links without having a page loaded.

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

No branches or pull requests

2 participants