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

skip empty URLs when inlining images #320

Closed
wants to merge 3 commits into from
Closed

Conversation

anarcat
Copy link
Contributor

@anarcat anarcat commented Mar 15, 2018

Description

Markdown links like [foo](), while basically invalid, do not usually
cause too much trouble, or at least shouldn't cause problems in
unrelated code. It so happens that if a document happens to have such
a link, markdown-toggle-inline-images will crash with:

insert-file-contents-literally: not a regular file: /tmp/default-directory-path/

This patch fixes the problem by checking if the file path extracted
from the regex is empty before proceeding with treating it like an image.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have updated the documentation in the README.md file if necessary.
  • I have added an entry to CHANGES.md.
  • I have added tests to cover my changes.
  • All new and existing tests passed (using make test).

anarcat and others added 2 commits March 15, 2018 14:26
Markdown links like `[foo]()`, while basically invalid, do not usually
cause too much trouble, or at least shouldn't cause problems in
unrelated code. It so happens that if a document happens to have such
a link, `markdown-toggle-inline-images` will crash with:

    insert-file-contents-literally: not a regular file: /tmp/default-directory-path/

This patch fixes the problem by checking if the `file` path extracted
from the regex is empty before proceeding with treating it like an image.
@anarcat
Copy link
Contributor Author

anarcat commented Mar 15, 2018

no new tests fail, but i haven't added test cases for this bug because there's no test case for toggle-inline-images already. there is already an empty link in test-cases.txt so once a test is added for the toggle, this will kick in automatically..

@jrblevin
Copy link
Owner

Thanks for the patch! Applied as baf23cb.

@jrblevin jrblevin closed this May 26, 2018
@anarcat anarcat deleted the patch-1 branch May 26, 2018 13:11
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.

2 participants