{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2734","repository_url":"https://api.github.com/repos/ansible/ansible-modules-extras","labels_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2734/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2734/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-extras/issues/2734/events","html_url":"https://github.com/ansible/ansible-modules-extras/issues/2734","id":171420974,"number":2734,"title":"Slack does not escape/encode ampersand (&) correctly","user":{"login":"Lapixx","id":1859305,"avatar_url":"https://avatars.githubusercontent.com/u/1859305?v=3","gravatar_id":"","url":"https://api.github.com/users/Lapixx","html_url":"https://github.com/Lapixx","followers_url":"https://api.github.com/users/Lapixx/followers","following_url":"https://api.github.com/users/Lapixx/following{/other_user}","gists_url":"https://api.github.com/users/Lapixx/gists{/gist_id}","starred_url":"https://api.github.com/users/Lapixx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lapixx/subscriptions","organizations_url":"https://api.github.com/users/Lapixx/orgs","repos_url":"https://api.github.com/users/Lapixx/repos","events_url":"https://api.github.com/users/Lapixx/events{/privacy}","received_events_url":"https://api.github.com/users/Lapixx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-16T14:09:11Z","updated_at":"2016-08-16T14:09:11Z","closed_at":null,"body":"<!--- Verify first that your issue/request is not already reported in GitHub -->\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\nSlack module\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\nansible 2.1.1.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\n<!---\r\nMention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).\r\n-->\r\nN/A\r\n\r\n##### OS / ENVIRONMENT\r\n<!---\r\nMention the OS you are running Ansible from, and the OS you are\r\nmanaging, or say “N/A” for anything that is not platform-specific.\r\n-->\r\nMac OS X 10.11.4 (but probably N/A)\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\nWhenever the `msg` or a `text` inside `attachments` contains an ampersand (`&`), the Slack module fails with `HTTP Error 400: Bad Request`.\r\n\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor bugs, show exactly how to reproduce the problem.\r\nFor new features, show how the feature would be used.\r\n-->\r\nSimply try to send a slack notification and make sure there is a `\"&\"` somewhere in the `msg` parameter (or inside a `attachments[].text`).\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\n- name: Send slack test message\r\n  hosts: MyHost\r\n  tasks:\r\n    - slack:\r\n        token: \"xxx/yyy/zzz\"\r\n        channel: \"#my-channel\"\r\n        username: \"Ansible\"\r\n        msg: \"one & two\"\r\n```\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\nYou'd expect to correctly receive the slack notification containing `\"one & two\"` as the message.\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with high verbosity (-vvvv) -->\r\nThe module fails.\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\nfatal: [MyHost]: FAILED! => {\"changed\": false, \"failed\": true, \"invocation\": {\"module_args\": {\"attachments\": null, \"channel\": \"#my-channel\", \"color\": \"normal\", \"domain\": null, \"icon_emoji\": null, \"icon_url\": \"http://www.ansible.com/favicon.ico\", \"link_names\": 1, \"msg\": \"one & two\", \"parse\": null, \"token\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"username\": \"Ansible\", \"validate_certs\": true}, \"module_name\": \"slack\"}, \"msg\": \" failed to send payload={\\\"username\\\": \\\"Ansible\\\", \\\"text\\\": \\\"one & two\\\", \\\"link_names\\\": 1, \\\"channel\\\": \\\"#my-channel\\\", \\\"icon_url\\\": \\\"http://www.ansible.com/favicon.ico\\\"} to https://hooks.slack.com/services/[obscured]: HTTP Error 400: Bad Request\"}\r\n```\r\n\r\n##### Temporary workaround\r\nI found that when I manually replace all `&` with `%26d` (URL escaped ampersand), I receive the correct notification."}}
{"actor":{"display_login":"Lapixx"}}