{"action":"created","issue":{"url":"https://api.github.com/repos/jimmywarting/StreamSaver.js/issues/22","repository_url":"https://api.github.com/repos/jimmywarting/StreamSaver.js","labels_url":"https://api.github.com/repos/jimmywarting/StreamSaver.js/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/jimmywarting/StreamSaver.js/issues/22/comments","events_url":"https://api.github.com/repos/jimmywarting/StreamSaver.js/issues/22/events","html_url":"https://github.com/jimmywarting/StreamSaver.js/pull/22","id":175065595,"number":22,"title":"Filename should be enclosed with quotation marks.","user":{"login":"vobruba-martin","id":6897988,"avatar_url":"https://avatars.githubusercontent.com/u/6897988?v=3","gravatar_id":"","url":"https://api.github.com/users/vobruba-martin","html_url":"https://github.com/vobruba-martin","followers_url":"https://api.github.com/users/vobruba-martin/followers","following_url":"https://api.github.com/users/vobruba-martin/following{/other_user}","gists_url":"https://api.github.com/users/vobruba-martin/gists{/gist_id}","starred_url":"https://api.github.com/users/vobruba-martin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vobruba-martin/subscriptions","organizations_url":"https://api.github.com/users/vobruba-martin/orgs","repos_url":"https://api.github.com/users/vobruba-martin/repos","events_url":"https://api.github.com/users/vobruba-martin/events{/privacy}","received_events_url":"https://api.github.com/users/vobruba-martin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-09-05T12:53:42Z","updated_at":"2016-09-05T19:06:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jimmywarting/StreamSaver.js/pulls/22","html_url":"https://github.com/jimmywarting/StreamSaver.js/pull/22","diff_url":"https://github.com/jimmywarting/StreamSaver.js/pull/22.diff","patch_url":"https://github.com/jimmywarting/StreamSaver.js/pull/22.patch"},"body":"For example if you have a comma in your filename then browser will not\r\nbe able to fully read it."},"comment":{"url":"https://api.github.com/repos/jimmywarting/StreamSaver.js/issues/comments/244800311","html_url":"https://github.com/jimmywarting/StreamSaver.js/pull/22#issuecomment-244800311","issue_url":"https://api.github.com/repos/jimmywarting/StreamSaver.js/issues/22","id":244800311,"user":{"login":"jimmywarting","id":1148376,"avatar_url":"https://avatars.githubusercontent.com/u/1148376?v=3","gravatar_id":"","url":"https://api.github.com/users/jimmywarting","html_url":"https://github.com/jimmywarting","followers_url":"https://api.github.com/users/jimmywarting/followers","following_url":"https://api.github.com/users/jimmywarting/following{/other_user}","gists_url":"https://api.github.com/users/jimmywarting/gists{/gist_id}","starred_url":"https://api.github.com/users/jimmywarting/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimmywarting/subscriptions","organizations_url":"https://api.github.com/users/jimmywarting/orgs","repos_url":"https://api.github.com/users/jimmywarting/repos","events_url":"https://api.github.com/users/jimmywarting/events{/privacy}","received_events_url":"https://api.github.com/users/jimmywarting/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T19:06:21Z","updated_at":"2016-09-05T19:06:21Z","body":"According to this [Special characters in content-disposition filename](http://stackoverflow.com/questions/7967079/special-characters-in-content-disposition-filename) question\r\nRFC 5987 is probably enough if we are going to use `content-disposition` header and have it work for all character \r\n\r\nmozilla have posted something here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent\r\n```javascript\r\nvar fileName = 'my file(2).txt';\r\nvar header = \"Content-Disposition: attachment; filename*=UTF-8''\" \r\n             + encodeRFC5987ValueChars(fileName);\r\n\r\nconsole.log(header); \r\n// logs \"Content-Disposition: attachment; filename*=UTF-8''my%20file%282%29.txt\"\r\n\r\n\r\nfunction encodeRFC5987ValueChars (str) {\r\n    return encodeURIComponent(str).\r\n        // Note that although RFC3986 reserves \"!\", RFC5987 does not,\r\n        // so we do not need to escape it\r\n        replace(/['()]/g, escape). // i.e., %27 %28 %29\r\n        replace(/\\*/g, '%2A')\r\n}\r\n```\r\n\r\nI did also export out the most important functionality out of [jshttp/content-disposition](https://github.com/jshttp/content-disposition) (removing parse + changing it to es6)\r\nEnded up with this:\r\n\r\n```javascript\r\nvar contentDisposition = ((( \r\n\tENCODE_URL_REGEXP = /[\\x00-\\x20\"'\\(\\)*,\\/:;<=>?@\\[\\\\\\]\\{\\}\\x7f]/g,\r\n\tHEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/,\r\n\tNON_LATIN1_REGEXP = /[^\\x20-\\x7e\\xa0-\\xff]/g,\r\n\tQUOTE_REGEXP = /([\\\\\"])/g,\r\n\tTEXT_REGEXP = /^[\\x20-\\x7e\\x80-\\xff]+$/,\r\n\tpencode = a => (a = a.charCodeAt(0).toString(16).toUpperCase(), '%' + ('0'+a).slice(-2))\r\n) => value => {\r\n\tlet \r\n\tobj = {},\r\n\tisQuotedString = TEXT_REGEXP.test(value),\r\n\tlatin1 = value.replace(NON_LATIN1_REGEXP, \"?\"),\r\n\tfallback = latin1 !== value\r\n\t\r\n\tif (fallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(value)) \r\n\t\tobj[\"filename*\"] = value\r\n\t\r\n\tif (isQuotedString || fallback) \r\n\t\tobj.filename = fallback ? latin1 : value\r\n\t\r\n\tvalue = \"attachment\"\r\n\t\r\n\tfor (let key of Object.keys(obj).sort()) {\r\n\t\tvalue += `; ${key}=` + (~key.indexOf('*') \r\n\t\t\t? \"UTF-8''\" + encodeURIComponent(obj[key]).replace(ENCODE_URL_REGEXP, pencode)\r\n\t\t\t: `\"${obj[key].replace(QUOTE_REGEXP, \"\\\\$1\")}\"`)\r\n\t}\r\n\t\r\n\treturn value\r\n}))()\r\n\r\nconsole.log(contentDisposition('∫ maths.pdf'))\r\n// attachment; filename=\"? maths.pdf\"; filename*=UTF-8''%E2%88%AB%20maths.pdf\r\nundefined\r\n```\r\n"}}
{"actor":{"display_login":"jimmywarting"}}