• Joe Tsai's avatar
    archive/zip: restrict UTF-8 detection for comment and name fields · 78805c07
    Joe Tsai authored
    CL 39570 added support for automatically setting flag bit 11 to
    indicate that the filename and comment fields are encoded in UTF-8,
    which is (conventionally) the encoding using for most Go strings.
    
    However, the detection added is too lose for two reasons:
    * We need to ensure both fields are at least possibly UTF-8.
    That is, if any field is definitely not UTF-8, then we can't set the bit.
    * The utf8.ValidRune returns true for utf8.RuneError, which iterating
    over a Go string automatically returns for invalid UTF-8.
    Thus, we manually check for that value.
    
    Updates #22367
    Updates #10741
    
    Change-Id: Ie8aae388432e546e44c6bebd06a00434373ca99e
    Reviewed-on: https://go-review.googlesource.com/72791Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    78805c07
Name
Last commit
Last update
..
tar Loading commit data...
zip Loading commit data...