Incomplete validation of the MediaType in isDataURI function
Description of the problem
The isDataURI function is used to check a Data URI in base64, including the MediaType, Attribute and Data.
The regular expression validating the MediaType is the following:
/^[a-z]+\/[a-z0-9\-\+]+$/i;
However, the latter does not include the "." character which is sometimes present in MediaType, for example in the MIME of Excels files:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Proposed solution
To correct this problem, we would have to correct this regular expression to include the dot, here is a proposed solution that works for my use case:
/^[a-z]+\/[a-z0-9\-\+\.]+$/i
It is then enough to modify the code of the file "\node_modules\validator\lib\isDataURI.js" as follows:
validMediaType = /^[a-z]+\/[a-z0-9\-\+\.]+$/i;
Additional context Validator.js version: v13.7.0 Node.js version: v16.13.1
Can i work on this?
For sure!
Hi @WikiRik,
Ended up working on another issue and just put up the PR: https://github.com/validatorjs/validator.js/pull/1998
Thank you, Sami
I am working on this issue. Will be raising a PR soon.
Hi all,
this has been fixed with PR #1916 already, which has been merged into master since April.
Thank you all for your contribution and for the fix !