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

datauri fails to accept valid data URIs. #518

Open
puellanivis opened this issue Sep 20, 2019 · 1 comment
Open

datauri fails to accept valid data URIs. #518

puellanivis opened this issue Sep 20, 2019 · 1 comment
Assignees
Labels

Comments

@puellanivis
Copy link

puellanivis commented Sep 20, 2019

Package version eg. v8, v9:

master

Code sample, to showcase or reproduce:

fmt.Println(dataURIRegex.MatchString(`data:,ohai`)

Prints false it should print true.

This is an inherited problem from every other validation library out there. This same regex keeps getting copied around.

Wikipedia gives a pretty clear guidance about what a valid Data URI is: data:[<media type>][;base64],<data> note the optional state of <media type> and even of the ;base64 element, and the requirement of a comma.

@deankarn
Copy link
Contributor

@puellanivis thanks for reporting, can you make a PR to correct?

@deankarn deankarn self-assigned this Sep 20, 2019
@deankarn deankarn added the bug label Sep 20, 2019
JonathanWThom added a commit to JonathanWThom/validator that referenced this issue Nov 22, 2019
Fixes Or Enhances go-playground#518.

Make sure that you've checked the boxes below before you submit PR:

[x] Tests exist or have been written that cover this particular change.
Change Details:

The datauri validation was not allowing certain valid strings; this
commit updates the regex to meet RFC 2397. I drew heavily on this gist
https://gist.github.com/khanzadimahdi/bab8a3416bdb764b9eda5b38b35735b8,
but had to make a few updates to remove some negative lookaheads (which
Go doesn't allow afaik), and to account for the way the `isDataURI`
function works - it validates the base64 separately from the other parts
of the uri.

@go-playground/admins
fairyhunter13 added a commit to fairyhunter13/validator that referenced this issue Jul 12, 2020
Fixes Or Enhances go-playground#518.

Make sure that you've checked the boxes below before you submit PR:

[x] Tests exist or have been written that cover this particular change.
Change Details:

The datauri validation was not allowing certain valid strings; this
commit updates the regex to meet RFC 2397. I drew heavily on this gist
https://gist.github.com/khanzadimahdi/bab8a3416bdb764b9eda5b38b35735b8,
but had to make a few updates to remove some negative lookaheads (which
Go doesn't allow afaik), and to account for the way the `isDataURI`
function works - it validates the base64 separately from the other parts
of the uri.

@go-playground/admins
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

2 participants