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

Quotes in URL field are not escaped and produce invalid HTML output #242

Open
adomasven opened this issue Mar 28, 2024 · 2 comments
Open

Comments

@adomasven
Copy link

Items with URL field that contain a quote mark " produce HTML bibliography output that is invalid with styles that output links, e.g. in Vancouver with an URL field https://example.com/" you get:

<div class="csl-entry">Example Domain. [cited 2024 Mar 28]. Available from: <a href="https://example.com/"">https://example.com/"</a></div>

Note <a href="https://example.com/""> with double quotes at the end of the href attribute.

When generating the HTML output the quote mark should be escaped with %22.

See zotero/zotero#3890 zotero/zotero-google-docs-integration#51

@larsgw
Copy link
Collaborator

larsgw commented Mar 28, 2024

The place to edit would be here:

citeproc-js/src/formats.js

Lines 136 to 145 in 59fbf78

"@URL/true": function (state, str) {
return "<a href=\"" + str + "\">" + str + "</a>";
},
"@DOI/true": function (state, str) {
var doiurl = str;
if (!str.match(/^https?:\/\//)) {
doiurl = "https://doi.org/" + str;
}
return "<a href=\"" + doiurl + "\">" + str + "</a>";
}

@larsgw
Copy link
Collaborator

larsgw commented Mar 28, 2024

Some first thoughts:

  • Input URLs may be encoded or decoded, so we cannot simply call encodeURI()
  • decodeURI() can fail on some decoded input URLs (e.g. https://example.org/%)

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