Some filenames make attachments in bug reports that are not downloadable

Bug #2048406 reported by Laurent Lyaudet
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Confirmed
Low
Unassigned

Bug Description

Hello :),

I have been uploading several screenshots for a few bug reports on Launchpad.
And I cannot download them after submitting.
I think the problem comes from the fact that screen captures made in Ubuntu (I'm using Mantic Minotaur 23.10 right now.) have spaces, accents apostrophe (not single quote) in it.

Example :

For this bug :
https://bugs.launchpad.net/ubuntu/+source/vim/+bug/1380110
I uploaded a screenshot named "Capture d’écran du 2023-12-05 22-45-04.png"

The link in the bug report has this URL:
https://bugs.launchpad.net/ubuntu/+source/vim/+bug/1380110/+attachment/5726518/+files/Capture%20d%E2%80%99%C3%A9cran%20du%202023-12-05%2022-45-04.png

But it doesn't work.
I assume this is just a problem that the filename is normalized before creating the file in your EDM (Electronic Document Management).
And it should probably be sufficient to just apply the same normalization before URL escaping the filename in the link.

Best regards,
    Laurent Lyaudet

Revision history for this message
Laurent Lyaudet (laurent-lyaudet) wrote :

If this is blocking your work, let us know by asking a question at Launchpad Support . Include the error ID OOPS-54aef76c49d9f3b9eddf746cde8a151b in your message.

Revision history for this message
Laurent Lyaudet (laurent-lyaudet) wrote :

I downloaded the source code of launchpad.
It seems the URL processing for file download is done here:
lib/lp/services/librarian/browser.py
```
    @stepthrough("+files")
    def traverse_files(self, filename):
        """Traverse on filename in the archive domain."""
        if not check_permission(self.file_navigation_permission, self.context):
            raise Unauthorized()
        library_file = self.context.getFileByName(filename)
        ...
```
It should work if filename argument in this method is obtained by parsing and cutting:
https://bugs.launchpad.net/ubuntu/+source/vim/+bug/1380110/+attachment/5726518/+files/Capture%20d%E2%80%99%C3%A9cran%20du%202023-12-05%2022-45-04.png
like this :
b"Capture%20d%E2%80%99%C3%A9cran%20du%202023-12-05%2022-45-04.png"
as bytes should be URL unencoded to:
b"Capture d\xE2\x80\x99\xC3\xA9cran du 2023-12-05 22-45-04.png"
Then it should be decoded from UTF-8:
b"Capture d\xE2\x80\x99\xC3\xA9cran du 2023-12-05 22-45-04.png".decode("UTF-8")
to give
"Capture d’écran du 2023-12-05 22-45-04.png"
and the method getFileByName(filename) should work.

Revision history for this message
Laurent Lyaudet (laurent-lyaudet) wrote :

Note that the link is constructed like this:
lib/lp/services/librarian/browser.py
```
@delegate_to(ILibraryFileAlias)
class ProxiedLibraryFileAlias:
...
        traversal_url = urlappend(parent_url, "+files")
        url = urlappend(
            traversal_url,
            url_path_quote(self.context.filename.encode("utf-8")),
        )
```

I think the line `url_path_quote(self.context.filename.encode("utf-8")),` is an unrelated bug.
'/' should be escaped in the filename.

Revision history for this message
Laurent Lyaudet (laurent-lyaudet) wrote :

`def quote(string, safe='/', encoding=None, errors=None):`
called as `quote(self.context.filename.encode("utf-8"), safe="")` seems more correct to me.

Revision history for this message
Guruprasad (lgp171188) wrote :

Hi Laurent, thank you for reporting this issue to us. I checked your attachment on the bug and can confirm that the issue is happening indeed. And thank you for providing useful information about the code that is handling this too. We will look into this soon.

Changed in launchpad:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Laurent Lyaudet (laurent-lyaudet) wrote :

Hello Guruprasad :)
You're welcome :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.