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

Commit

Permalink
Bugfix for escaping strings in correct place.
Browse files Browse the repository at this point in the history
  • Loading branch information
benkamphaus committed Sep 11, 2014
2 parents c0b42c2 + 652b567 commit 68e2b47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions transit/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def emit_nil(self, _, as_map_key, cache):
return self.emit_string(ESC, "_", None, True, cache) if as_map_key else self.emit_object(None)

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

marshal_dispatch = {"_": Marshaler.emit_nil,
"?": Marshaler.emit_boolean,
"s": lambda self, rep, as_map_key, cache: Marshaler.emit_string(self, "", "", rep, as_map_key, cache),
"s": lambda self, rep, as_map_key, cache: Marshaler.emit_string(self, "", "", escape(rep), as_map_key, cache),
"i": lambda self, rep, as_map_key, cache: Marshaler.emit_int(self, "i", rep, as_map_key, cache),
"n": lambda self, rep, as_map_key, cache: Marshaler.emit_int(self, "n", rep, as_map_key, cache),
"d": Marshaler.emit_double,
Expand Down Expand Up @@ -383,7 +383,7 @@ def _init_handlers(self):
self.handlers = self._verbose_handlers(WriteHandler())

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

def emit_map(self, m, _, cache):
self.emit_map_start(len(m))
Expand Down

0 comments on commit 68e2b47

Please sign in to comment.