org.hl7.fhir.core
org.hl7.fhir.core copied to clipboard
Mime type checking can't handle dash character
Hi,
The most recent version of the Validator complains when it encounters the following URL in the narrative of a resource: data:application/octet-stream;base64,volmacht
, with the message:
The URL is not valid because '(The mimetype portion of the data: URL is not valid (Mime type invalid) in URL: data:application/octet-stream;base64,volmacht)': data:application/octet-stream;base64,volmacht
See test.zip for the offending file.
So it claims 'application/octet-stream' is not a valid mime type, although it actually is valid. I think this is due to the checkValidMimeType
method in InstanceValidator.java. Here, the following regex is used to check for validity of the mime type:
^(\w+|\*)\/(\w+|\*)((;\s*(\w+)=\s*(\S+))?)$
However, the \w
character class doesn't include the normal dash, although this character is allowed and quite common in the subtype part of mime types. Changing the regex to something like:
^(\w+|\*)\/([\w-]+|\*)((;\s*(\w+)=\s*(\S+))?)$
should probably solve the problem.