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

Single character literals do not work #20

Open
ErisDS opened this issue Jul 17, 2018 · 0 comments
Open

Single character literals do not work #20

ErisDS opened this issue Jul 17, 2018 · 0 comments
Labels
bug Something isn't working

Comments

@ErisDS
Copy link
Member

ErisDS commented Jul 17, 2018

Originally reported at TryGhost/GQL#24 & TryGhost/Ghost#8433


To reproduce:

  • On a local blog...
  • Create a post with the title A, the slug will be a. Publish the post.
  • Create a post with the title AB, the slug will be ab. Publish the post.
  • Visit the frontend of the blog to grab the client secret.
  • Open postman
  • Try doing a get request for http://localhost:2368/ghost/api/v0.1/posts?client_id=ghost-frontend&client_secret=[client-secret]&filter=slug:ab - see that it works
  • Try doing a get request for http://localhost:2368/ghost/api/v0.1/posts?client_id=ghost-frontend&client_secret=[client-secret]&filter=slug:a - see that it doesn't work

I believe this is due to the plus sign here: https://github.com/TryGhost/GQL/blob/master/src/gql.l#L22

The badcharsincnot regex matches a single character, and then the second group matches a second character. Therefore there must be at least 2 chars for a match.

Fixing this may have other implications, if so, we should close this issue and instead, add a rule that literals must be at least 2 characters to the documentation, provide tests to demo this limitation + if possible, improve the error message.

@ErisDS ErisDS added the bug Something isn't working label Jul 17, 2018
ErisDS referenced this issue in TryGhost/NQL-Lang Jul 17, 2018
closes #2

- There should be no restriction on the length of a literal
- This is a horrible bug that has always existed in the language
- Fixed by changing the format of the literal token to expect 1 valid start char followed by 0 or more chars
NOTE:
- This also had an impact on colon processing
- As a result of this fix, it is now invalid to have a colon at the start of a literal
- We can revisit this if it turns out to be a problem
@daniellockyer daniellockyer transferred this issue from TryGhost/NQL-Lang Mar 1, 2022
mike182uk added a commit to mike182uk/Ghost that referenced this issue May 17, 2023
…errors

refs TryGhost/Product#3224

When a product has a slug that is a single letter, checking if a user had
access to view a post associated with that product would cause a 500 error.
The underlying cause of this issue is TryGhost/NQL#20
This fix circumvents this issue by providing a value that the nql lexer
will not error out on
mike182uk added a commit to mike182uk/Ghost that referenced this issue May 17, 2023
refs TryGhost/Product#3224

When a product has a slug that is a single letter, checking if a user had
access to view a post associated with that product would cause a 500 error.
The underlying cause of this issue is TryGhost/NQL#20
This fix circumvents this issue by providing a value that the nql lexer
will not error out on
mike182uk added a commit to mike182uk/Ghost that referenced this issue May 18, 2023
refs TryGhost/Product#3224

When a product has a slug that is a single letter, checking if a user had
access to view a post associated with that product would cause a 500 error.
The underlying cause of this issue is TryGhost/NQL#20
This fix circumvents this issue by providing a value that the nql lexer
will not error out on
mike182uk added a commit to TryGhost/Ghost that referenced this issue May 18, 2023
refs TryGhost/Product#3224

When a product has a slug that is a single letter, checking if a user
had access to view a post associated with that product would cause a 500
error. The underlying cause of this issue is
TryGhost/NQL#20 This fix circumvents this
issue by providing a value that the nql lexer will not error out on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant