fix(file-ops): surrogatepass in bytes_written encode (review finding)
Content that flowed through a surrogateescape decode (backend output via patch_replace) can carry lone surrogates; a strict encode raises UnicodeEncodeError where the old wc -c path could not. Mirrors the existing sha256 verification encode.
This commit is contained in:
parent
eb78ab235f
commit
fcae5ad49a
|
|
@ -1593,8 +1593,11 @@ class ShellFileOperations(FileOperations):
|
|||
|
||||
# Get bytes written — compute from the content we just wrote
|
||||
# (len(content.encode('utf-8')) matches wc -c for UTF-8) instead
|
||||
# of spawning a ``wc -c`` subprocess.
|
||||
bytes_written = len(content.encode('utf-8'))
|
||||
# of spawning a ``wc -c`` subprocess. ``surrogatepass`` mirrors the
|
||||
# sha256 verification block below: content that flowed through a
|
||||
# surrogateescape decode (backend output via patch_replace) may
|
||||
# carry lone surrogates a strict encode would reject.
|
||||
bytes_written = len(content.encode('utf-8', 'surrogatepass'))
|
||||
|
||||
# Post-write content verification (cheap, one shell call): compare
|
||||
# the on-disk sha256 to the intended content's hash. Production
|
||||
|
|
|
|||
Loading…
Reference in New Issue