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

Parsing of localpart without ›@‹ is not possible #4

Open
JaSpa opened this issue Nov 6, 2020 · 1 comment
Open

Parsing of localpart without ›@‹ is not possible #4

JaSpa opened this issue Nov 6, 2020 · 1 comment

Comments

@JaSpa
Copy link

JaSpa commented Nov 6, 2020

I needed to parse only localparts of mail addresses and came across this library but realized that it wasn't working as I thought it would:

parseOnly (localPartP Strict) "test"
-- Left "local part > quoted content > '\"': Failed reading: satisfy"

parseOnly (localPartP Lenient) "test"
-- Left "local part: Failed reading: empty"

parseOnly (localPartP Strict) "test@"
-- Right (Nothing,LocalPart "test")

parseOnly (localPartP Lenient) "test@"
-- Right (Nothing,LocalPart "test")

But I also know that the @ is not consumed by localPartP because this parser succeeds:

parseOnly (localPartP Lenient <* char '@') "test@"
-- Right (Nothing,LocalPart "test")

So I don't know if this is to be considered a bug or if localPartP needs documentation that it can only succeed if it is followed by a @.

For my use case this won't be a blocker either way since I decided to parse only a restricted form of localparts and use your nice library to do validation afterwards.

@pjones
Copy link
Owner

pjones commented Nov 6, 2020

@JaSpa Thanks for point this out. localPartP does indeed peek at the character following the local part and verifies that it is a "@" character. IIRC I did this because of some weird edge case with obsolete local parts. I'll play with the code and see if I can lift this restriction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants