Endpoints do not correctly support URI-Ms containing query strings
Closed this issue · 0 comments
shawnmjones commented
MementoEmbed trims the query string off of URI-Ms:
- http://wayback.archive-it.org/2823/20110911114626/http://www.nzherald.co.nz/world/news/article.cfm?c_id=2&objectid=10750223 leads to a social card for the wrong URI-M
- http://wayback.archive-it.org/2017/20101026004107/http://www.defense.gov/news/newsarticle.aspx?id=61411 gives an error that the memento is not present in the archive
The problem exists in all services due to an incorrect assumption of how the path:subpath
variable is handled by Flask. Code for the social card service is below:
MementoEmbed/mementoembed/services/product.py
Lines 107 to 124 in 224e866
Instead of returning the rest of the path within the variable subpath
on line 110, Flask instead strips off the query string and stores it in the args
array of its request
object. The path
method of the request
object does not have the query string, either.
This can be fixed by:
- rebuilding the URI-M using the
query_string
member of therequest
object - getting the full path requested from the
full_path
member of therequest
object and removing the service endpoint from this string, essentially ignoring the<path:subpath>
capabilities of Flask altogether, replacing line 110 with something like- option 1:
urim = request.full_path.replace('/services/product/socialcard/', '')
- this can be made service-specific - option 2:
urim = request.full_path[29:]
- this is also service specific, but avoids any potential string collisions with the actual URI-M
- option 1:
This will also have to be repeated for all service endpoints:
/services/product/thumbnail/
/services/product/socialcard/
/services/memento/contentdata/
/services/memento/bestimage/
/services/memento/archivedata/
/services/memento/originalresourcedata/