Fix the `Download Diff` issue in Chrome (v16 or newer) when filename has comma(s).
Review Request #6786 — Created Jan. 16, 2015 and submitted
If a diff file with a comma in the filename was uploaded via the web UI, clicking "Download Diff" could present an error about "Multiple Content-Disposition" when running with Chrome 16 or newer.
The problem is that we use the Content-Disposition header to tell the browser what filename to save as, but commas in this header are interpreted as multiple values.
To fix this, before we assemble the Content-Disposition header, we replace all commas in the diffset filename with underscores.
- Wrote a unit test, in the test, I set the diffset.name as 'test, comma'.
- Unit test passed.
- Unit test failed whitout the fix.
Description | From | Last Updated |
---|---|---|
Col: 80 E501 line too long (97 > 79 characters) |
reviewbot | |
Typo - "Chrom" - "Chrome". Perhaps you should just generalize this and put above this line: # Some older browsers … |
mike_conley | |
Col: 73 W291 trailing whitespace |
reviewbot | |
Come to think of it, it might be a good idea to refer to the issue # itself here. So … |
mike_conley | |
Another type-o - "nmae" -> "name". |
mike_conley | |
Blank line between these. "No.3704" doesn't indicate what this is. Better to provide a link to the bug. |
chipx86 | |
This doesn't seem related to the fix. |
chipx86 | |
Just a reminder, we'd still like to see a unit test added for this. |
david | |
Does this test fail if you comment out the change in views.py? I don't see you setting a filename with … |
david | |
Col: 51 E211 whitespace before '[' |
reviewbot | |
Col: 29 E127 continuation line over-indented for visual indent |
reviewbot | |
This still doesn't test the failure case because there's no comma in the filename! Please comment out your change in … |
david | |
Col: 51 E211 whitespace before '[' |
reviewbot | |
Col: 29 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 41 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 51 E211 whitespace before '[' |
reviewbot | |
Col: 29 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 51 E211 whitespace before '[' |
reviewbot |
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py
- Description:
-
~ change reviewsboard/revies/views.py to be compatible with old version chrome(v16)
~ change reviewsboard/revies/views.py to be compatible with old version chrome(v16). When you Download Diff on some specific page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so just need to swap it with an underscore
- Bugs:
- Description:
-
~ change reviewsboard/revies/views.py to be compatible with old version chrome(v16). When you Download Diff on some specific page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so just need to swap it with an underscore
~ change reviewboard/revies/views.py to be compatible with old version chrome(v16). When you Download Diff on some specific page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so just need to swap it with an underscore
-
-
Come to think of it, it might be a good idea to refer to the issue # itself here. So maybe your comment can become:
"This next bit fixes issue 3704, where Multiple Content-Disposition error pages were shown on older versions of Chrome when attempting to download a diff with a comma in the filename. We workaround this by replacing commas with underscores."
-
- Description:
-
~ change reviewboard/revies/views.py to be compatible with old version chrome(v16). When you Download Diff on some specific page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so just need to swap it with an underscore
~ I modify reviewboard/reviews/views.py to be compatible with old version Chrome(v16 or older). When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so I just need to replace it with an underscore. - Commit:
-
e5c45027a971ae4141a7e4127aae677942004d4441b81a934859df2ddce7bbff051cc32f0eb5c6c9
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/admin/scmtools/repository/rbtools_setup.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/admin/scmtools/repository/rbtools_setup.html
-
Hi Chester,
views.py
is a pretty big file, and most of it is fine with Chrome. Can you update the summary describing more precisely what's being made compatible? Remember, someone unfamiliar with the codebase should be able to know what you're fixing.The description should also clearly explain the problem you're solving, why it was broken, and how you're solving it, at a high level.
-
Along with this, I'd like to see a unit test that verifies the resulting filename is what we expect. Unit tests are very important to our product, so it's good to start learning with simple ones like this.
-
Blank line between these.
"No.3704" doesn't indicate what this is. Better to provide a link to the bug.
-
- Summary:
-
Modify reviewboard/reviews/views.py `Download Diff` function to be compatible with old version ChromeModify reviewboard/reviews/views.py to fix Download Diff to be compatible with old versions of Chrome (v16 or older)
- Commit:
-
41b81a934859df2ddce7bbff051cc32f0eb5c6c95bd8aab37de65ea84fd5e1d02e62637839a5847b
-
Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py Tool: Pyflakes Processed Files: reviewboard/reviews/views.py
- Summary:
-
Modify reviewboard/reviews/views.py to fix Download Diff to be compatible with old versions of Chrome (v16 or older)Modify reviewboard/reviews/views.py to fix Download Diff to be compatible with some versions of Chrome (v16 or newer)
- Commit:
-
5bd8aab37de65ea84fd5e1d02e62637839a5847b222adb61f0dbb3d2b23c9ca9170a3a8bb213b02d
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py
- Description:
-
~ I modify reviewboard/reviews/views.py to be compatible with old version Chrome(v16 or older). When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so I just need to replace it with an underscore.~ I modify reviewboard/reviews/views.py to be compatible with some versions of Chrome(v16 or newer). When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so I just need to replace it with an underscore.
- Description:
-
~ I modify reviewboard/reviews/views.py to be compatible with some versions of Chrome(v16 or newer). When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, so I just need to replace it with an underscore.~ I modify reviewboard/reviews/views.py to be compatible with some versions of Chrome(v16 or newer). When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, whendiffset.name != 'diff'
, so I just need to replace it with an underscore. - Testing Done:
-
~ Only ran reviews/tests module, passed.
~ - Wrote a unit test, in the test, I set the diffset.name as 'test'.
+ - Unit test passed.
- Commit:
-
b3a57e8eabf07938ad0150f5ede3519e61b7b633bde64b37f2e317fc39ef5d30de606e35bd152c01
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py reviewboard/reviews/tests.py Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py reviewboard/reviews/tests.py
-
-
-
- Testing Done:
-
~ - Wrote a unit test, in the test, I set the diffset.name as 'test'.
~ - Wrote a unit test, in the test, I set the diffset.name as 'test, comma'.
- Unit test passed.
+ - Unit test failed whitout the fix.
- Commit:
-
c2d762fd2a4e6a4052ec0597bf3dafc267f49e500dad998601897a8eea24100fbbe419876ee3b4f2
-
The patch looks good! However, I've got a few nitpicks regarding your description. We generally don't use the first person (I) when writing descriptions. They usually don't reference the author at all. You also don't usually need to mention the files that changed (or code examples); just provide a high level overview of the changes. (e.g., "Previously when X occured, Y would happen because Z. This has been fixed to do the correct behaviour: ABC"..., etc.)
- Description:
-
~ I modify reviewboard/reviews/views.py to be compatible with some versions of Chrome(v16 or newer). When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on Chrome. It's caused by the comma in the filename, whendiffset.name != 'diff'
, so I just need to replace it with an underscore.~ When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on some versions of Chrome(v16 or newer).+ + This iss caused by the comma in the filename from
reviewboard/reviews/views.py
'sdiffset
, whendiffset.name != 'diff'
anddiffset.name
has at least one comma.+ + This change replaces the comman with the underscore.
- Description:
-
~ When you click
Download Diff
on some code review page, there might be "Multiple Content-Disposition" error page on some versions of Chrome(v16 or newer).~ If a diff file with a comma in the filename was uploaded via the web UI, clicking "Download Diff" could present an error about "Multiple Content-Disposition" when running with Chrome 16 or newer.
~ This iss caused by the comma in the filename from
reviewboard/reviews/views.py
'sdiffset
, whendiffset.name != 'diff'
anddiffset.name
has at least one comma.~ The problem is that we use the Content-Disposition header to tell the browser what filename to save as, but commas in this header are interpreted as multiple values.
~ This change replaces the comman with the underscore.
~ To fix this, before we assemble the Content-Disposition header, we replace all commas in the diffset filename with underscores.