Skip to content

Fix worldcat links have spaces#12653

Merged
mekarpeles merged 2 commits into
internetarchive:masterfrom
cdrini:fix/worldcat-link-spaces
May 6, 2026
Merged

Fix worldcat links have spaces#12653
mekarpeles merged 2 commits into
internetarchive:masterfrom
cdrini:fix/worldcat-link-spaces

Conversation

@cdrini
Copy link
Copy Markdown
Collaborator

@cdrini cdrini commented May 6, 2026

Fix. This is showing up in our modsecurity as "abusive traffic", but it's actually just the macro's whitespace being included in the URL. It appears some clients/browsers don't string the white space from the URL, and instead try to then go to a url like openlibrary.org/ http://worldcat...

Technical

Testing

Confirmed worldcat links still render correctly: https://testing.openlibrary.org/works/OL11327425W/Prisoner_in_paradise?edition=key%3A/books/OL10691191M

Screenshot

Stakeholders

Copilot AI review requested due to automatic review settings May 6, 2026 18:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to stop whitespace from being included in the generated WorldCat URL on edition pages (which is currently triggering ModSecurity as “abusive traffic”), by removing the whitespace-producing URL macro and generating the href directly.

Changes:

  • Removes the WorldcatUrl macro and shifts URL construction into WorldcatLink.
  • Updates the edition view template to pass a single oclc_number and use the renamed worldcat_link variable.
  • Refactors the WorldcatLink macro to choose between OCLC vs ISBN URLs inline.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
openlibrary/templates/type/edition/view.html Renames variables and changes the WorldCat macro invocation to use oclc_number and worldcat_link.
openlibrary/macros/WorldcatUrl.html Deletes the URL-only macro that could inject leading whitespace into URLs.
openlibrary/macros/WorldcatLink.html Inlines the WorldCat URL generation logic into the <a href=...> attribute.

Comment thread openlibrary/macros/WorldcatLink.html Outdated
Comment thread openlibrary/macros/WorldcatLink.html Outdated
@cdrini cdrini force-pushed the fix/worldcat-link-spaces branch from 4387483 to f13dcca Compare May 6, 2026 18:56
@cdrini cdrini changed the title Fix worldcat link have spaces Fix worldcat links have spaces May 6, 2026
@mekarpeles mekarpeles merged commit 7515f48 into internetarchive:master May 6, 2026
3 checks passed
@cdrini cdrini deleted the fix/worldcat-link-spaces branch May 6, 2026 23:56
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.

3 participants