{"action":"created","issue":{"url":"https://api.github.com/repos/instructure/canvas-lms/issues/617","labels_url":"https://api.github.com/repos/instructure/canvas-lms/issues/617/labels{/name}","comments_url":"https://api.github.com/repos/instructure/canvas-lms/issues/617/comments","events_url":"https://api.github.com/repos/instructure/canvas-lms/issues/617/events","html_url":"https://github.com/instructure/canvas-lms/pull/617","id":67405442,"number":617,"title":"[Solving Bug] Solving send data truncated bug","user":{"login":"Kulgar","id":856044,"avatar_url":"https://avatars.githubusercontent.com/u/856044?v=3","gravatar_id":"","url":"https://api.github.com/users/Kulgar","html_url":"https://github.com/Kulgar","followers_url":"https://api.github.com/users/Kulgar/followers","following_url":"https://api.github.com/users/Kulgar/following{/other_user}","gists_url":"https://api.github.com/users/Kulgar/gists{/gist_id}","starred_url":"https://api.github.com/users/Kulgar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kulgar/subscriptions","organizations_url":"https://api.github.com/users/Kulgar/orgs","repos_url":"https://api.github.com/users/Kulgar/repos","events_url":"https://api.github.com/users/Kulgar/events{/privacy}","received_events_url":"https://api.github.com/users/Kulgar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-09T17:00:15Z","updated_at":"2015-04-09T17:06:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/instructure/canvas-lms/pulls/617","html_url":"https://github.com/instructure/canvas-lms/pull/617","diff_url":"https://github.com/instructure/canvas-lms/pull/617.diff","patch_url":"https://github.com/instructure/canvas-lms/pull/617.patch"},"body":"Hi everyone, \r\n\r\nI have discovered a new bug and quite a tricky one. \r\n\r\nHow to reproduce it:\r\n* find any action controller that uses the \"send_data\" method (to export a CSV for instance, like gradebook.csv),\r\n* create data with multibytes characters (in users' names for instance), those data must be included in the ones you want to export, \r\n* export those data, the file you get should miss some characters at the end of the file, you can check the file you get by comparing it to a CSV that you generate using the ruby console, \r\n\r\nOne of my exported files (gradebook.csv) was truncated because of multibytes characters in users' names. \r\n\r\nI did a lot of reverse engineering and I finally discovered that you were somewhat supercharging the send_data method in \"config/initializers/action_pack.rb\" by defining the \"Content-Length\" header. \r\n\r\nI did some research and came across this issue: https://rails.lighthouseapp.com/projects/8994/tickets/2661-fix-for-send_data-content-length-header-in-ruby-19\r\n\r\nThis was related to Ruby On Rails 2.3.4 but it is the exact same issue. Looking at their patch I found that for ruby > 1.9 they are now using \"bytesize\" method instead of \"length\" for this header. \r\n\r\nSo I'm offering this fix which does exactly that and which solves my truncated data issue. \r\n\r\nLet me know if you need any further information,\r\nRegis\r\n\r\nOriginal PR: #616"},"comment":{"url":"https://api.github.com/repos/instructure/canvas-lms/issues/comments/91293439","html_url":"https://github.com/instructure/canvas-lms/pull/617#issuecomment-91293439","issue_url":"https://api.github.com/repos/instructure/canvas-lms/issues/617","id":91293439,"user":{"login":"ccutrer","id":191320,"avatar_url":"https://avatars.githubusercontent.com/u/191320?v=3","gravatar_id":"","url":"https://api.github.com/users/ccutrer","html_url":"https://github.com/ccutrer","followers_url":"https://api.github.com/users/ccutrer/followers","following_url":"https://api.github.com/users/ccutrer/following{/other_user}","gists_url":"https://api.github.com/users/ccutrer/gists{/gist_id}","starred_url":"https://api.github.com/users/ccutrer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccutrer/subscriptions","organizations_url":"https://api.github.com/users/ccutrer/orgs","repos_url":"https://api.github.com/users/ccutrer/repos","events_url":"https://api.github.com/users/ccutrer/events{/privacy}","received_events_url":"https://api.github.com/users/ccutrer/received_events","type":"User","site_admin":false},"created_at":"2015-04-09T17:06:33Z","updated_at":"2015-04-09T17:06:33Z","body":"do you think you could come up with a spec to test this?"}}