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

API should handle unescaped URIs #5101

Closed
supermarin opened this Issue Nov 12, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@supermarin
Copy link

supermarin commented Nov 12, 2015

Triggering jobs via API requires the user to manually escape slashes into %2F.
It makes the URI harder to read, because escaping happens only in the slug:

    curl --silent --request POST --data "$body" \
        --header "Content-Type: application/json" \
        --header "Accept: application/json" \
        --header "Travis-API-Version: 3" \
        --header "Authorization: token $TRAVIS_TOKEN" \
        "https://api.travis-ci.com/repo/user%2Frepo/requests"

And it makes the end user do terrible things like this to invoke jobs:

travis_slug=${GITHUB_SLUG//\//%2F}
@rkh

This comment has been minimized.

Copy link
Member

rkh commented Nov 13, 2015

I'm very 👎 on this. It's causing issues in our old API at the moment (try calling your repository "settings" or "requests").

Escaping happens properly as defined by RFC 6570 and RFC 3986.

If the URI is not written by hand, but generated, I would recommend to do proper URI escaping in the first place. Better yet, actually use a URI Template library. That way you'll make sure this easily works with Travis Enterprise.

Not 100% sure what the best way in Bash would be, in Ruby I'd do something like this:

require 'addressable/template'

# this can also be programatically discovered by fetching https://api.travis-ci.com/
template = 'https://api.travis-ci.com/repo/{repository.slug}/requests'
url      = template.expand("repository.slug" => "user/repo")

HTTP.post(url, ...)
@BanzaiMan

This comment has been minimized.

Copy link
Member

BanzaiMan commented Feb 26, 2016

Closing for now.

@BanzaiMan BanzaiMan closed this Feb 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment