Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit 68e2b47

Browse files
committed
Bugfix for escaping strings in correct place.
2 parents c0b42c2 + 652b567 commit 68e2b47

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

transit/writer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def emit_nil(self, _, as_map_key, cache):
101101
return self.emit_string(ESC, "_", None, True, cache) if as_map_key else self.emit_object(None)
102102

103103
def emit_string(self, prefix, tag, string, as_map_key, cache):
104-
encoded = cache.encode(str(prefix)+tag+escape(string), as_map_key)
104+
encoded = cache.encode(str(prefix)+tag+string, as_map_key)
105105
# TODO: Remove this optimization for the time being - it breaks the cache
106106
#if "cache_enabled" in self.opts and is_cacheable(encoded, as_map_key):
107107
# return self.emit_object(cache.value_to_key[encoded], as_map_key)
@@ -222,7 +222,7 @@ def register(self, obj_type, handler_class):
222222

223223
marshal_dispatch = {"_": Marshaler.emit_nil,
224224
"?": Marshaler.emit_boolean,
225-
"s": lambda self, rep, as_map_key, cache: Marshaler.emit_string(self, "", "", rep, as_map_key, cache),
225+
"s": lambda self, rep, as_map_key, cache: Marshaler.emit_string(self, "", "", escape(rep), as_map_key, cache),
226226
"i": lambda self, rep, as_map_key, cache: Marshaler.emit_int(self, "i", rep, as_map_key, cache),
227227
"n": lambda self, rep, as_map_key, cache: Marshaler.emit_int(self, "n", rep, as_map_key, cache),
228228
"d": Marshaler.emit_double,
@@ -383,7 +383,7 @@ def _init_handlers(self):
383383
self.handlers = self._verbose_handlers(WriteHandler())
384384

385385
def emit_string(self, prefix, tag, string, as_map_key, cache):
386-
return self.emit_object(unicode(prefix) + tag + escape(string), as_map_key)
386+
return self.emit_object(unicode(prefix) + tag + string, as_map_key)
387387

388388
def emit_map(self, m, _, cache):
389389
self.emit_map_start(len(m))

0 commit comments

Comments
 (0)