dan2097 / opsin

Open Parser for Systematic IUPAC Nomenclature. Chemical name to structure conversion
https://opsin.ch.cam.ac.uk
MIT License
158 stars 32 forks source link

forward slashes cause problems #233

Closed IsomerDesign closed 11 months ago

IsomerDesign commented 1 year ago

This works: 4-tert-butyl This causes problems: 4-/tert-butyl

This is an "innocent mistake". I use / in my names as markup for "put the next token in italic font." I'm not aware of any use of / in IUPAC names, so in that sense it's not a problem. Still, it would probably be wise to filter it or escape it to avoid 404 errors under the hood.

dan2097 commented 11 months ago

If I recall the 404 errors are due to an issue with how the chemistry department's web server handles requests containing this character. Specifically for "security" reasons they're not allowed even when correctly escaped in a request. i.e. OPSIN doesn't even recieve the request if it contains a forward slash hence giving the 404.

I'm not currently sure of the best approach to resolving this. I could (and probably should) add support for POST requests which would be uneffected by this, but this doesn't really help with the problem when OPSIN is used to produce images directly from names as ideally that does require a URL e.g. https://opsin.ch.cam.ac.uk/opsin/<name>.png

If I recall forward slashes are legitimately allowed by OPSIN in only two places (R/S) and (+/-) and in both cases the / is optional. As I'm not sure that format is common I don't think it makes sense to support it directly in OPSIN.

As a pragmatic workaround I've changed opsin.ch.cam.ac.uk to strip forward slashes from the names submitted to it.

IsomerDesign commented 11 months ago

That seems a reasonable solution to me. Thank you.