Skip to content

'Base URL Redirects' doesn't check redirect location #113

@ronjakoi

Description

@ronjakoi

There should be a check here:

else:
# we must have redirected if our url is not what was requested
result.tests.append('redirect')
return result

to ensure that the redirect ends up in the right location. Something like:

        elif newurl != result.make_info_url():
            print(newurl)
            raise ValidatorError('url-check', newurl, result.make_info_url(), result, 'Failed to redirect from url: {}.'.format(url))
        else:
            # we must have redirected if our url is not what was requested and matches result.make_info_url()
            result.tests.append('redirect')
            return result
    

Right now, this test is happy as long as the request redirects to any location that is different from the original request location:

(venv) ronja@longjing:~/src/iiif-image-validator$ iiif-validate.py -v -i 67352ccc-d1b0-11e1-89ae-279075081939.png -s localhost:8080 -p test_image --test=baseurl_redirect --version=3.0
Importing 3
[1] test baseurl_redirect PASS
  url: []
  tests: ['redirect']

Done (1 tests, 0 failures)
(venv) ronja@longjing:~/src/iiif-image-validator$ curl -i http://localhost:8080/test_image/67352ccc-d1b0-11e1-89ae-279075081939.png
HTTP/1.1 307 Temporary Redirect
location: /wrong/place
vary: origin, access-control-request-method, access-control-request-headers
access-control-allow-origin: *
content-length: 0
date: Wed, 14 Jan 2026 19:26:07 GMT

(venv) ronja@longjing:~/src/iiif-image-validator$ curl -i http://localhost:8080/test_image/67352ccc-d1b0-11e1-89ae-279075081939.png/info.json
HTTP/1.1 200 OK
content-type: application/ld+json;profile="http://iiif.io/api/image/3/context.json"
vary: origin, access-control-request-method, access-control-request-headers
access-control-allow-origin: *
content-length: 480
date: Wed, 14 Jan 2026 19:27:14 GMT

{"@context":"http://iiif.io/api/image/3/context.json","id":"http://localhost:8080/test_image/67352ccc-d1b0-11e1-89ae-279075081939.png","type":"ImageService3","protocol":"http://iiif.io/api/image","profile":"level2","width":1000,"height":1000,"maxWidth":10000,"maxHeight":10000,"maxArea":50000000,"extraFeatures":["baseUriRedirect","cors","mirroring","profileLinkHeader","regionByPct","regionByPx","regionSquare","rotationBy90s","sizeByConfinedWh","sizeByH","sizeByPct","sizeByW"]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions