Repository navigation
Remove query and fragment from doi.org links when parsing DOIs - #17713
Conversation
PR Summary by QodoStrip query and fragment from doi.org links when parsing DOIs
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1. Cleanup truncates encoded DOI suffixes
|
| /// Call this before URL decoding, because an encoded `%3F` or `%23` is a valid part of a DOI. | ||
| private static String removeTrackingParameters(String doi) { | ||
| String trimmed = doi.trim(); | ||
| if (DOI_RESOLVER_PREFIX.matcher(trimmed).find()) { |
There was a problem hiding this comment.
doi.org/bfrhmx parses correctly, but doi.org/bfrhmx?utm_source=x returns empty. Could we handle the tracking parameter for this short DOI form too and add a regression test?
|
@doraem-on Thanks For the Suggestion , its Done. https://doi.org:443/.. links are now also cleaned and so I added a test case for it in DOTest.java. |
doraem-on
left a comment
There was a problem hiding this comment.
Thanks for fixing the :443 case. I retested doi.org/bfrhmx?utm_source=x and it still fails, while doi.org/bfrhmx works. Could you handle that once
|
@doraem-on Thanks a lot for the testing and code review |
…m/AnishKmSingh/jabref into fix-17689-doi-tracking-parameters
|
@doraem-on |
|
The failing |
|
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin port-17713-to-black-forest
git worktree add --checkout .worktree/port-17713-to-black-forest port-17713-to-black-forest
cd .worktree/port-17713-to-black-forest
git reset --hard HEAD^
git cherry-pick -x be8eb38efb1417758479f63926c4d05a7f207176 |
* refs/heads/main: Chore(deps): Bump gradle-wrapper from 9.8.2 to 9.9.0 (#17753) New Crowdin updates (#17745) Remove task notification when a task fails (#17124) Store keyring secrets without extra encryption and migrate legacy values (#13687) (#17504) Mark Library as modified after merging changes from a backup file (#17632) Remove query and fragment from doi.org links when parsing DOIs (#17713) Document AI layering architecture example in developer documentation (#17737) Extract key binding dispatching from MainTable (#17564)
* main: (26 commits) Diagnose stalled GUI tests and align dependency versions (JabRef#17763) Keep entry table still while a search match is in view (JabRef#16905) Add BibSonomy as a web search fetcher (JabRef#17611) Chore(deps): Bump com.konghq:unirest-modules-gson from 4.11.3 to 4.11.4 in /versions (JabRef#17761) Apply KeyBindingDispatcher to entry editor, linked files and frame (JabRef#17571) Chore(deps): Bump org.hisp.dhis:json-tree from 1.12.0 to 1.13.0 in /versions (JabRef#17759) Chore(deps): Bump com.dlsc.pdfviewfx:pdfviewfx from 3.6.0 to 3.6.1 in /versions (JabRef#17760) Chore(deps): Bump io.github.classgraph:classgraph from 6.0.1 to 6.0.2 in /versions (JabRef#17758) Chore(deps): Bump tools.jackson:jackson-bom from 3.2.4 to 3.3.0 in /versions (JabRef#17757) Chore(deps): Bump com.nimbusds:oauth2-oidc-sdk from 11.38.2 to 11.39 in /versions (JabRef#17756) Chore(deps): Bump tools.maran:svg-materialdesign from 1.0.0 to 1.0.1 in /versions (JabRef#17754) Chore(deps): Bump com.konghq:unirest-java-core from 4.11.3 to 4.11.4 in /versions (JabRef#17755) Chore(deps): Bump gradle-wrapper from 9.8.2 to 9.9.0 (JabRef#17753) New Crowdin updates (JabRef#17745) Remove task notification when a task fails (JabRef#17124) Store keyring secrets without extra encryption and migrate legacy values (JabRef#13687) (JabRef#17504) Mark Library as modified after merging changes from a backup file (JabRef#17632) Remove query and fragment from doi.org links when parsing DOIs (JabRef#17713) Document AI layering architecture example in developer documentation (JabRef#17737) Extract key binding dispatching from MainTable (JabRef#17564) ... # Conflicts: # jabkit/src/test/java/org/jabref/toolkit/service/ExportServiceTest.java
Summary
When the DOI field contained a doi.org link with tracking parameters (eg.
?utm_source=newsletter) so "Copy DOI URL" kept them as part of DOI , encoded the?as%3Fand so it produce a broken link ("DOI NOT FOUND"). Now DOI.parse() removes the query and fragment from doi.org URLs before decoding so now the copied link is clean and open the Article.I only do this for doi.org/ dx.doi.org links , because some other sites put the DOI inside the query (like
Link.aspx?doi=10.5520/...). I also do it before decoding because an encoded%3Fcan be a real part of DOI and should stay.This also helps other features that uses
DOI.parse()like opening the DOI link and DOI cleanup.Steps to test
https://doi.org/10.1371/journal.pone.0000308?utm_source=newsletter.Expected: the copied link is
https://doi.org/10.1371/journal.pone.0000308?utm_source=newsletterand the article opens.Before fix:


After fix:

Related issues and pull requests
Closes #17689
AI usage
I used Claude(claude-opus-5.5) to understand the issue clearly and DOI parsing code to find the root cause and to draft changes and tests. Claude also pointed out the two edge cases (DOI inside the query of non-doi.org URLs and encoded %3F being part of real DOI).
I reproduce the bug myself went though every change until I understood why it needed applied changes in my local checkout , resolved the rebase conflict , ran DOITest and URLUtilTest locally and manually tested the fix in running JabRef(ScreenShot above). I take full ownership of code and can explain any part of it.
Checklist
CHANGELOG.mddescribing the change from the user's point of view (if the change is visible to the user)