rd-alliance / metadata-catalog-v2

RDA Metadata Standards Catalog, version 2
MIT License
10 stars 3 forks source link

'/' not handled correctly in the browse by subject #10

Closed yurj closed 1 year ago

yurj commented 1 year ago

Hi!

in the "Browse by subject", if I click on "Information/library standards" (https://rdamsc.bath.ac.uk/subject/Information/library%20standards) I get 404 Not Found. I think because of the '/' in the subject name.

alex-ball commented 1 year ago

Yes, the slash is the issue. Escaping the slash won't work (pallets/werkzeug#797), but as there's no further structure expected under "/subject/" it looks like using the converter would be the cleanest way to deal with this.

yurj commented 1 year ago

in https://rdamsc.bath.ac.uk/subject-index there's https://rdamsc.bath.ac.uk/subject/Information%2Flibrary%20standards which still does not work but changing %2F to / it works: https://rdamsc.bath.ac.uk/subject/Information/library%20standards.

I've made a local installation from the github code and it has the same problem.

alex-ball commented 1 year ago

This behaviour does not occur when running the native development server on Linux:

export FLASK_APP=rdamsc; venv/bin/flask --debug run

But you're right, it does exhibit under production Apache/WSGI, even though according to the Werkzeug issue linked above it shouldn't be possible for Flask to distinguish / and %2F. Looks like I will have to include some logic to force all platforms to behave identically.

alex-ball commented 1 year ago

Okay, this is my fault for not reading the Apache docs in full. By default Apache rejects all URLs with "%2F" in them with a 404.

If I understand correctly, to get the code to work as currently written, you would need the following in your Apache configuration:

AllowEncodedSlashes On

(This will convert "%2F" to "/" and is the same behaviour as the built-in development/mock testing server).

But I've added a line in the /subjects/ route that allows %252F in the URL as well, and also what I would prefer the Apache configuration to be:

AllowEncodedSlashes NoDecode