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

When making a call to a URL with an ampersand it replaces the & with & #236

Closed
tslape opened this issue Dec 27, 2016 · 6 comments
Closed

Comments

@tslape
Copy link

tslape commented Dec 27, 2016

While making a call that contains an ampersand in the signed URL from S3, it replaces the & with & amp ; causing a 403 forbidden error.

The URL is being set in a Javascript function afterReponse from the previous call.

@MosayebG
Copy link

I have this issue too.

@hassy
Copy link
Member

hassy commented Jan 4, 2017

Do you have a reproducible test case?

@tslape
Copy link
Author

tslape commented Jan 4, 2017


{
    "config": {
        "target": "https://www.facebook.com",
        "timeout": 9,
        "phases": [
            {"duration": 1, "arrivalRate":1}
        ],
        "processor": "./MyFunctions.js"
    },
    "headers": {
    },
    "scenarios": [
        {
            "flow": [
                {
                    "get":{
                        "beforeRequest": "setJSONBody",
                        "url": "/GitHub/photos/a.395084243927205.1073741825.262588213843476/839624966139795/?type=1&theater",
                        "afterResponse": "setURL"
                    }
                },
                {
                    "get":{
                        "beforeRequest": "setJSONBody",
                        "url": "{{ url }}",
                        "afterResponse": "response"
                    }
                }
            ]
        }
    ]
}



module.exports = {
    setJSONBody: setJSONBody,
    setURL: setURL,
    response: response
}

function setJSONBody(requestParams, context, ee, next) {
    return next(); // MUST be called for the scenario to continue
}

function setURL(requestParams, response, context, ee, next) {
    console.log(requestParams.uri)
    context.vars['url']= '/GitHub/photos/a.395084243927205.1073741825.262588213843476/839624966139795/?type=1&theater';
    return next(); // MUST be called for the scenario to continue
}


function response(requestParams, response, context, ee, next) {
    console.log(requestParams.uri)
    return next(); // MUST be called for the scenario to continue
}

The console will display


\https://www.facebook.com/GitHub/photos/a.395084243927205.1073741825.262588213843476/839624966139795/?type=1&theater
 |https://www.facebook.com/GitHub/photos/a.395084243927205.1073741825.262588213843476/839624966139795/?type=1&theater

Facebook does not have an issue with the ampersand being encoded but it was where I was able to get a URL that had one. The issue occurs internally with files that are in S3 and have signed URLs and AWS does not view the encoded value as valid.

@hassy
Copy link
Member

hassy commented Jan 4, 2017

Thanks @tslape. You can set requestParams.uri directly instead of using a template variable. If you need the variable, use {{{ url }}} to prevent it from being HTML-encoded.

@tslape
Copy link
Author

tslape commented Jan 4, 2017

Thank you @hassy, using {{{ url }}} worked to prevent the encoding.

It may be useful to add this into the documents in the "Advanced: writing custom logic in Javascript" section.

@hassy
Copy link
Member

hassy commented Jan 10, 2017

Fixed in artilleryio/artillery-core#139

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