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

fix(plain_text): partition is not distinguishing file extensions correctly #129

Closed
wants to merge 1 commit into from

Conversation

Iced0368
Copy link
Contributor

@Iced0368 Iced0368 commented Mar 11, 2024

if replace_wikilinks:
            for w in parsed.wikilinks:
                b, e = w.span
                title = w.title
                if title[:1] != ':' and (
                    title.partition(':')[2].partition('.')[2]
                    in KNOWN_FILE_EXTENSIONS
                ):
                    remove(b, e)  # image

At line 743 of _wikitext.py, it calls partition to separate the extension from the file name. However, in this case, if the file name contains '.', the extension cannot be obtained correctly.

For example, [[File:Julia set (C = 0.285, 0.01).jpg]] is not recognized as a file because the extension is separated by '285, 0.01).jpg', and this problem is solved simply by replacing partition with rpartition.

…ectly

At line 743 of _wikitext.py, it calls partition to separate the extension from the file name.
However, in this case, if the file name contains '.', the extension cannot be obtained correctly.

For example, [File:Julia set (C = 0.285, 0.01).jpg]] is not recognized as a file because the extension is separated by '285, 0.01).jpg', and this problem is solved simply by replacing partition with rpartition.
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (19b9ff2) to head (7c3cd92).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #129   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         2234      2234           
=========================================
  Hits          2234      2234           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@5j9
Copy link
Owner

5j9 commented Mar 11, 2024

Thank you! Merged via b6c7fc0 (I followed github command-line instructions to merge, don't know why it left this PR open). Released as v0.55.9.

@5j9 5j9 closed this Mar 11, 2024
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