• Matt Giuca's avatar
    Fixed downloaded filenames containing percent-encoded characters. · 25c6a34f
    Matt Giuca authored
    Servers set the download filename in a URL syntax (either through the
    Content-Disposition header, or in the filename of the requested URL
    itself). Previously, characters would remain percent-encoded when saved
    to disk, if they are deemed unsuitable for display. This criteria makes
    no sense for setting a filename.
    
    Cases included:
    - Control characters.
    - Path separators.
    - Special URL characters such as '%', '+', '&' and '#'.
    - Spoofing characters, such as invisible characters.
    
    Now, all characters are unescaped. Characters that are illegal in
    filenames (such as control characters, path separators, colons, etc) are
    converted into underscores. Other characters are left bare.
    
    Fixed and added tests.
    
    Bug: 849794
    Change-Id: I797ee3d6aa8b803d9a7227e821fd8b4d55d0c58d
    Reviewed-on: https://chromium-review.googlesource.com/1209003Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
    Commit-Queue: Matt Giuca <mgiuca@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#589386}
    25c6a34f
http_content_disposition.cc 13.6 KB