tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4ac13e89818ca3dfd3d088c41cb6acb55e6a7895
parent 8431db84585d23668551c6035f1256cf79f78332
Author: Andrew McCreight <continuation@gmail.com>
Date:   Sat, 10 Jan 2026 16:10:36 +0000

Bug 2009519 - Fix format escaping in vendor_manifest.py. r=tjr DONTBUILD

The strings passed to self.log() are interpreted as format strings,
so directly splicing in strings, like say C++ patches, via f strings or
whatever that could contain braces can cause issues. Instead, use the
formatting facility of self.log(). For consistency, I have eliminated
all use of Python format strings from the strings passed in to self.log,
even though some of these are integers or file names which are unlikely
to contain braces.

Differential Revision: https://phabricator.services.mozilla.com/D278557

Diffstat:
Mpython/mozbuild/mozbuild/vendor/vendor_manifest.py | 27+++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/python/mozbuild/mozbuild/vendor/vendor_manifest.py b/python/mozbuild/mozbuild/vendor/vendor_manifest.py @@ -850,12 +850,15 @@ class VendorManifest(MozbuildObject): self.log( logging.WARNING, "header_files_warning", - {}, + { + "num_headers": len(header_files_to_add), + "headers": header_files_to_add, + }, ( - "We found %s header files in the update, pass --add-to-exports if you want" - + " to attempt to include them in EXPORTS blocks: %s" - ) - % (len(header_files_to_add), header_files_to_add), + "We found {num_headers} header files in the update, pass " + + "--add-to-exports if you want to attempt to include them " + + "in EXPORTS blocks: {header_files_to_add}" + ), ) self.logInfo( @@ -871,8 +874,8 @@ class VendorManifest(MozbuildObject): self.log( logging.ERROR, "vendor", - {}, - "Could not add %s to the appropriate moz.build file" % f, + {"f": f}, + "Could not add {f} to the appropriate moz.build file", ) should_abort = True @@ -883,8 +886,8 @@ class VendorManifest(MozbuildObject): self.log( logging.ERROR, "vendor", - {}, - "Could not remove %s from the appropriate moz.build file" % f, + {"f": f}, + "Could not remove {f} from the appropriate moz.build file", ) should_abort = True @@ -935,8 +938,8 @@ class VendorManifest(MozbuildObject): self.log( logging.ERROR, "vendor", - {}, - f"Patch rejection details:\n{reject_content}", + {"reject_content": reject_content}, + "Patch rejection details:\n{reject_content}", ) raise e finally: @@ -953,5 +956,5 @@ class VendorManifest(MozbuildObject): ) msgs.append("I am going to re-throw the exception now.") for m in msgs: - self.log(logging.WARN, "vendor", {}, m) + self.log(logging.WARN, "vendor", {"m": m}, "{m}") raise e