Skip to content

Commit

Permalink
Added extra URL decoding to ID field for IIIF's info.json. Fixes #270
Browse files Browse the repository at this point in the history
  • Loading branch information
ruven committed Sep 6, 2024
1 parent ce0232e commit 0b9b301
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
06/09/2024:
- Added extra URL decoding to ID field for IIIF's info.json. Fixes https://github.com/ruven/iipsrv/issues/270


05/09/2024:
- Added convenience function to Rawtile class to duplicate bands for encoders that cannot natively handle
single band monochrome images: simplifies WebP encoding.
Expand Down
11 changes: 8 additions & 3 deletions src/IIIF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,16 @@ void IIIF::run( Session* session, const string& src )
string scheme = session->headers["HTTPS"].empty() ? "http://" : "https://";

if (request_uri.empty()){
throw invalid_argument( "IIIF: REQUEST_URI was not set in FastCGI request, so the ID parameter cannot be set." );
throw invalid_argument( "IIIF: REQUEST_URI was not set in FastCGI request, so the ID parameter cannot be set" );
}

request_uri.erase( request_uri.length() - suffix.length() - 1, string::npos );
id = scheme + session->headers["HTTP_HOST"] + request_uri;
// Need to decode in case URL is encoded
URL uri( request_uri );
string decoded_uri = uri.decode();

// Remove the suffix and the preceding "/"
decoded_uri.erase( decoded_uri.length() - suffix.length() - 1, string::npos );
id = scheme + session->headers["HTTP_HOST"] + decoded_uri;
}

// Decode and escape any URL-encoded characters from our file name for JSON
Expand Down

0 comments on commit 0b9b301

Please sign in to comment.