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

Can't route url which contains some char likes #\space #2

Open
C-Entropy opened this issue Mar 14, 2021 · 4 comments
Open

Can't route url which contains some char likes #\space #2

C-Entropy opened this issue Mar 14, 2021 · 4 comments

Comments

@C-Entropy
Copy link

When visit something like 127.0.0.1/a%20a it will give error like this:
There was an error processing your request: Parse error:URI "/a a" contains illegal character #\ at position 2.%
It turns out to because this.
Clack will return decoded url, which may contains something like #\space and it looks like puri(puri:parse-uri) can't handle it.

It may have more to do with cl-routes, but it looks like there are no new progress since 2017.

@svetlyak40wt
Copy link
Member

If Clack returns the decoded URL, then probably we don't need to decode it again.

@C-Entropy
Copy link
Author

I have tried

(defun get-route (path)
  "Returns a route, matched on given path.
   If none matched, then returns nil.
   Path should be a string."
  (check-type path string)
  (routes:match *routes* (quri:url-encode path)))

But it doesn't work, since quri:url-encode will encode / into %2F, leads different results.
For example, try this:

(puri:uri-parsed-path (puri:parse-uri "/Attic/Media/wallpaper/81566390_pa0.png"))
(puri:uri-parsed-path (puri:parse-uri (quri:url-encode "/Attic/Media/wallpaper/81566390_pa0.png")))

I can't find function from puri to process this.
Maybe write another function on it?

@C-Entropy
Copy link
Author

I have noticed that there are two routes system in weblocks.
One is routes.lisp, inside weblocks, another is weblocks-navigation-widget.
Why is there even two?
Is it possible to merge them into one? Is there any benefit doing so?

@C-Entropy C-Entropy changed the title Can't parse url which contains some char likes #\space Can't route url which contains some char likes #\space Mar 15, 2021
@C-Entropy
Copy link
Author

For now, I use this as a work around:

(defun get-route (path)
  "Returns a route, matched on given path.
   If none matched, then returns nil.

   Path should be a string."
  (check-type path string)
  (routes:match *routes* (cl-strings:replace-all (quri:url-encode path) "%2F" "/")))

But it may not handle case I mentioned here

@svetlyak40wt svetlyak40wt transferred this issue from 40ants/weblocks Jan 5, 2022
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