Skip to content

Proper Media Types parser #3498

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

Closed
develop7 opened this issue May 9, 2024 · 2 comments · Fixed by #4005
Closed

Proper Media Types parser #3498

develop7 opened this issue May 9, 2024 · 2 comments · Fixed by #4005
Assignees
Labels
difficulty: beginner Pure Haskell task hygiene cleanup or refactoring

Comments

@develop7
Copy link
Collaborator

develop7 commented May 9, 2024

Description of issue

Current parser breaks on media types like application/vnd.pgrst.plan;wat="application/json;text/csv" producing nonsense like ("application","vnd.pgrst.plan",[("wat","application/json"),("text/csv\"","")]) and doesn't handle escaped quotes well too.

We do use parsec in QueryParams BTW, so it's an obvious candidate to use here as well.

@wolfgangwalther wolfgangwalther added the hygiene cleanup or refactoring label May 9, 2024
@taimoorzaeem taimoorzaeem added the difficulty: beginner Pure Haskell task label Apr 7, 2025
@taimoorzaeem
Copy link
Collaborator

@steve-chavez I am thinking of giving this a go. We have quite some media type related issue so it might help. We have some bugs here as well:

params =
let rp = T.drop 1 restParams
in if T.null rp then [] else map param $ T.splitOn ";" rp -- FIXME: breaks if there's a ';' in a quoted value
param p =
let (k, v) = T.break (== '=') p
in (k, dropAround (== '"') $ T.drop 1 v) -- FIXME: doesn't unescape quotes in values
dropAround p = T.dropWhile p . T.dropWhileEnd p

I am good with parsec, so it should be easy.

@steve-chavez
Copy link
Member

@taimoorzaeem Sounds goods! Please go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: beginner Pure Haskell task hygiene cleanup or refactoring
Development

Successfully merging a pull request may close this issue.

4 participants