Open Bug 1846814 Opened 3 years ago Updated 3 years ago

Pasting in SVG as an attachment ends up producing a truncated file

Categories

(bugzilla.mozilla.org :: Bug Creation/Editing, defect)

Production
defect

Tracking

()

People

(Reporter: dholbert, Unassigned)

Details

Attachments

(4 files)

STR:

  1. Copy the source of https://bugzilla.mozilla.org/attachment.cgi?id=9346998 to your clipboard.
  2. Click "Attach new file" on a bug (e.g. this one here)
  3. Focus the "File: " attachment textbox at the top of the page, and paste in the contents of your clipboard. Ensure that the final </svg> is present there.
  4. Type in some description, and choose "Content type: [SVG]" from the dropdown menu, and click Submit.
  5. Try to view the resulting attachment. View its source and be sure the closing </svg> is present.

EXPECTED RESULTS:
The attachment should be all there.

ACTUAL RESULTS:
The resulting attachment is truncated; i.e. it's missing some final close tags which makes it invalid SVG. I got these attachments when trying this:
https://bugzilla.mozilla.org/attachment.cgi?id=9346995
https://bugzilla.mozilla.org/attachment.cgi?id=9346996
(In the second one, when posting, I manually added a newline character at the very end, which caused the resulting file to be truncated slightly later, which might be a clue. Maybe somewhere we're undercounting the number of bytes to use for the file, due to the presence of multi-byte non-ASCII characters (the Hebrew IDs on some elements)?)

I ran into this in bug 1843799 FWIW; specifically, bug 1843799 comment 7 and bug 1843799 comment 8.

I'll now follow my own STR, here on this bug, first from Firefox Nightly, and then from Chrome, to see if it might be browser-specific.

The issue reproduces in both Firefox and Chrome. Chrome seems to get an interesting additional issue[1] first, but the issue described here is there as well, if you view the source of the attachments here. In both comment 2 and comment 3, the actual uploaded file ends with...

                    <polygon id="Rectangle-Copy-10" fill="#29D1DE" mask="url(#mask-2)" points="19 0 39.3255814 0 42 9 21.6744186 9"/>
                </g>
            </g>
        

(note the blank space present on the last line there)

...i.e. it's missing the final three close-tags from the content that I provided.

[1] The additional Chrome issue is that copypaste from their view-source seems to pick up an unwanted blank line at the start (regardless of where you paste). So if you perform all of the STR in Chrome (as I did to generate comment 3), then the resulting file generates an error due to the <?xml line being on the second line rather than the first. I'll file that as a bug in Chrome.

Here's a screencast of what I saw when uploading "file attached from Firefox", just to demonstrate what the bug looks like in practice.

(It looked essentially exactly the same when I uploaded the file from Chrome, aside from the aforementioned thing with the stray newline that Chrome puts at the start when copying from view-source.)

As a maybe-simpler approach, I'm trying posting the following here via the attachment form, as a plain text file:

Text at the start
רכיב-אני-רוצה
Text at the end

Let's see if it works.

Yup, that triggers the same issue -- the attachment is truncated. https://bugzilla.mozilla.org/attachment.cgi?id=9347025 ends with Text and is missing the final characters which should say at the end.

Interestingly, the file-preview that's shown inline at the very top of comment 6 is not truncated, though! So maybe Bugzilla is getting the whole file but getting inconsistently confused about the number of bytes, or something to that effect?

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: