Skip to content

Commit

Permalink
fix(lib): Fix string literals in protofile exports
Browse files Browse the repository at this point in the history
Should only affect python2/jython in burp
  • Loading branch information
rwinkelmaier-ncc committed Jun 3, 2024
1 parent 6961a89 commit 0576b80
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/blackboxprotobuf/lib/protofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@

def _print_message(message_name, typedef, output_file, depth=0):
# type: (str, TypeDef, TextIO, int) -> None
indent = " " * depth
indent = six.u(" ") * depth
if not NAME_REGEX.match(message_name):
raise TypedefException("Message name: %s is not valid" % message_name)

# sort typedef for better looking output
typedef = blackboxprotobuf.lib.api.sort_typedef(typedef)

message_name = message_name.strip()
output_file.write("\n")
output_file.write(six.u("\n"))
output_file.write(indent)
output_file.write("message %s {\n" % message_name)
output_file.write(six.u("message %s {\n") % message_name)
for field_number, field_typedef in typedef.items():
proto_type = None
field_name = None
Expand Down Expand Up @@ -155,7 +155,7 @@ def _print_message(message_name, typedef, output_file, depth=0):

output_file.write(indent)
output_file.write(
" %s%s %s = %s%s;\n"
six.u(" %s%s %s = %s%s;\n")
% (
"repeated " if is_repeated else "",
proto_type,
Expand All @@ -166,7 +166,7 @@ def _print_message(message_name, typedef, output_file, depth=0):
)

output_file.write(indent)
output_file.write("}\n\n")
output_file.write(six.u("}\n\n"))


def export_proto(typedef_map, output_filename=None, output_file=None, package=None):
Expand All @@ -184,9 +184,9 @@ def export_proto(typedef_map, output_filename=None, output_file=None, package=No
output_file = io.StringIO()

# preamble
output_file.write('syntax = "proto3";\n\n')
output_file.write(six.u('syntax = "proto3";\n\n'))
if package:
output_file.write("package %s;\n\n" % package)
output_file.write(six.u("package %s;\n\n") % package)

for typedef_name, typedef in typedef_map.items():
_print_message(typedef_name, typedef, output_file)
Expand Down

0 comments on commit 0576b80

Please sign in to comment.