{"action":"opened","issue":{"url":"https://api.github.com/repos/tus/tus-js-client/issues/41","repository_url":"https://api.github.com/repos/tus/tus-js-client","labels_url":"https://api.github.com/repos/tus/tus-js-client/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/tus/tus-js-client/issues/41/comments","events_url":"https://api.github.com/repos/tus/tus-js-client/issues/41/events","html_url":"https://github.com/tus/tus-js-client/issues/41","id":169780669,"number":41,"title":"Upload fails in Safari if meta field value is an empty string","user":{"login":"arturi","id":1199054,"avatar_url":"https://avatars.githubusercontent.com/u/1199054?v=3","gravatar_id":"","url":"https://api.github.com/users/arturi","html_url":"https://github.com/arturi","followers_url":"https://api.github.com/users/arturi/followers","following_url":"https://api.github.com/users/arturi/following{/other_user}","gists_url":"https://api.github.com/users/arturi/gists{/gist_id}","starred_url":"https://api.github.com/users/arturi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arturi/subscriptions","organizations_url":"https://api.github.com/users/arturi/orgs","repos_url":"https://api.github.com/users/arturi/repos","events_url":"https://api.github.com/users/arturi/events{/privacy}","received_events_url":"https://api.github.com/users/arturi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-07T05:23:40Z","updated_at":"2016-08-07T05:23:40Z","closed_at":null,"body":"To reproduce:\r\n\r\n``` javascript\r\nvar upload = new tus.Upload(file, {\r\n  endpoint: '/upload',\r\n  metadata: {\r\n    foo: \"hello\",\r\n    bar: \"world\",\r\n    nonlatin: \"słońce\",\r\n    empty: \"\"\r\n  }\r\n})\r\n```\r\n\r\nSafari says: `An invalid or illegal string was specified` when tus is setting the header here https://github.com/tus/tus-js-client/blob/master/lib/upload.js#L222-L228.\r\n\r\nPossible solutions: remove key if value is empty? But what if it’s intentional? Maybe set it to a string that’s empty (`'\"\"'`) like:\r\n\r\n``` javascript\r\nfor (var key in metadata) {\r\n  var value = metadata[key];\r\n  if (value === \"\") {\r\n    value = \"''\";\r\n  }\r\n  encoded.push(key + \" \" + Base64.encode(metadata[key]));\r\n}\r\n```\r\n\r\n- http://stackoverflow.com/questions/15212127/is-an-empty-string-valid-base64-encoded-data-of-zero-bytes-length\r\n- http://stackoverflow.com/questions/30621802/why-does-json-parse-fail-with-the-empty-string#answer-30621997"}}
{"actor":{"display_login":"arturi"}}