Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete validation of the MediaType in isDataURI function #1972

Closed
qmisslin opened this issue May 18, 2022 · 6 comments
Closed

Incomplete validation of the MediaType in isDataURI function #1972

qmisslin opened this issue May 18, 2022 · 6 comments
Labels

Comments

@qmisslin
Copy link

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

@samilieberman
Copy link
Contributor

Can i work on this?

@WikiRik
Copy link
Member

WikiRik commented Jul 5, 2022

For sure!

@samilieberman
Copy link
Contributor

Hi @WikiRik,

Ended up working on another issue and just put up the PR: #1998

Thank you,
Sami

@meeraj257
Copy link

I am working on this issue. Will be raising a PR soon.

@pano9000
Copy link
Contributor

pano9000 commented Dec 6, 2022

Hi all,

this has been fixed with PR #1916 already, which has been merged into master since April.

@qmisslin
Copy link
Author

qmisslin commented Dec 7, 2022

Thank you all for your contribution and for the fix !

@qmisslin qmisslin closed this as completed Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants