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

Gemini doesn't handle leading slashes #599

Closed
whikloj opened this issue Apr 13, 2017 · 7 comments
Closed

Gemini doesn't handle leading slashes #599

whikloj opened this issue Apr 13, 2017 · 7 comments

Comments

@whikloj
Copy link
Member

whikloj commented Apr 13, 2017

When testing Gemini I noticed that if your paths have a preceding slash they can be added but not queried.
For example

mysql> select * from Gemini;
+----+------------------------+-------------------+
| id | drupal                 | fedora            |
+----+------------------------+-------------------+
|  1 | /fedora_resource/jared | /container/1      |
|  2 | fedora_resource/22     | container/3       |
|  3 | /fedora_resource/bad   | /split_crate/oops |
|  5 | fedora_resource/woot   | there/it/is       |
+----+------------------------+-------------------+
4 rows in set (0.00 sec)
ubuntu@claw:~$ curl -i http://localhost:8083/drupal/fedora_resource/22
HTTP/1.1 200 OK
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:27:57 GMT

container/3

But

ubuntu@claw:~$ curl -i http://localhost:8083/drupal/fedora_resource/jared
HTTP/1.1 404 Not Found
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:29:17 GMT

Or more directly

ubuntu@claw:~$ curl -i -XPOST -H"Content-type: application/json" -d '{ "fedora" : "/my/new/path", "drupal" : "/super/cool" }' http://localhost:8083
HTTP/1.1 201 Created
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:31:48 GMT

ubuntu@claw:~$ curl -i http://localhost:8083/drupal/super/cool
HTTP/1.1 404 Not Found
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:32:28 GMT

We should either deal with preceding slashes or throw an error when adding them.

Thoughts?

@ruebot
Copy link
Member

ruebot commented Apr 13, 2017

Hrm, that should have been fixed with Islandora/chullo#64 ...I'll have to look closer at Gemini to make sure.

@whikloj
Copy link
Member Author

whikloj commented Apr 13, 2017

@ruebot oh maybe I didn't pull something in correctly?

@whikloj
Copy link
Member Author

whikloj commented Apr 13, 2017

@ruebot oh actually this wouldn't be that. This service never touches Fedora or Drupal, so Chullo wouldn't be involved.

@whikloj
Copy link
Member Author

whikloj commented Apr 13, 2017

It's right here https://github.com/Islandora-CLAW/Crayfish/blob/master/Gemini/src/app.php#L23-L26

> curl -i http://localhost:8083/drupal/super/cool
HTTP/1.1 404 Not Found
Host: localhost:8083
Connection: close
X-Powered-By: PHP/7.0.15-0ubuntu0.16.04.4
Cache-Control: no-cache, private
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Apr 2017 14:39:11 GMT

But an error_log() inside the getDrupalPath function shows

[Thu Apr 13 14:39:11 2017] drupal path is (super/cool)

That is stripping the front slash off, so when you get to the Path Mapping service you always get an item without a leading slash. So I would say we should just remove the leading slash in the insert function.

@whikloj
Copy link
Member Author

whikloj commented Apr 13, 2017

Either that or always add one

@dannylamb
Copy link
Contributor

good catch @whikloj. i'd sanitize input for consistency. it think i'd always remove it, since the base url is supposed to end with a slash.

@whikloj
Copy link
Member Author

whikloj commented Apr 28, 2017

Resolved with Islandora/Crayfish@4b55843

@whikloj whikloj closed this as completed Apr 28, 2017
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

3 participants