Skip to content

Commit 53e6208

Browse files
committed
Fix #2691 DOI with < and >
1 parent f046a05 commit 53e6208

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

scholia/app/templates/404-doi.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<script>
88
const Cite = require('citation-js').Cite
99
try {
10-
let example = new Cite('https://doi.org/{{ doi }}', { forceType: '@doi/api' })
10+
let example = new Cite('https://doi.org/{{ doi | urlencode }}', { forceType: '@doi/api' })
1111
let output = example.format('quickstatements')
1212
$( '#qs' ).text( output );
1313
output = encodeURIComponent(

scholia/app/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def register_converter(state):
9797
qs_pattern = r'<regex(r"Q[1-9]\d*(?:[^0-9]+Q[1-9]\d*)*"):qs>'
9898

9999
# https://www.crossref.org/blog/dois-and-matching-regular-expressions/
100-
DOI_PATTERN = re.compile(r'10\.\d{4,9}/[\[\]\-._;()/:A-Z0-9]+', re.IGNORECASE)
100+
DOI_PATTERN = re.compile(r'10\.\d{4,9}/[\[\]\-._;()/:A-Z0-9<>]+',
101+
re.IGNORECASE)
101102

102103
# pattern for aspects
103104
ASPECT_PATTERN = '<regex("[a-zA-Z]+"):aspect>'
@@ -1242,8 +1243,7 @@ def redirect_doi(doi):
12421243
DOI identifier.
12431244
12441245
"""
1245-
normalize_doi = remove_special_characters_url(doi)
1246-
qs = doi_to_qs(normalize_doi)
1246+
qs = doi_to_qs(doi)
12471247
if len(qs) > 0:
12481248
q = qs[0]
12491249
return redirect(url_for('app.show_work', q=q), code=302)

scholia/query.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ def doi_to_qs(doi):
376376
>>> doi_to_qs('10.1016/j.stem.2016.02.016') == ['Q23008981']
377377
True
378378
379+
>>> doi = '10.1002/1521-3951(200209)233:1<10::aid-pssb10>3.0.co;2-v'
380+
>>> doi_to_qs(doi) == ['Q135403558']
381+
True
382+
379383
"""
380384
query = 'select ?work where {{ ?work wdt:P356 "{doi}" }}'.format(
381385
doi=escape_string(doi.upper()))

0 commit comments

Comments
 (0)