From cb9b08b36923dae007f5ba68eb02a75a68ad122e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Oct 2019 15:58:24 +0530 Subject: [PATCH] Dont serialize the default namespace on ever tag --- src/calibre/srv/html_as_json.cpp | 2 +- src/calibre/srv/tests/content.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/calibre/srv/html_as_json.cpp b/src/calibre/srv/html_as_json.cpp index 3c3a0fff42..d2805b1659 100644 --- a/src/calibre/srv/html_as_json.cpp +++ b/src/calibre/srv/html_as_json.cpp @@ -311,7 +311,7 @@ class Serializer { } if (!write_str_literal("{\"n\":")) return false; if (!this->write_string_as_json(tag_name)) return false; - if (nsindex > -1) { + if (nsindex > 0) { char buf[32]; this->write_data(buf, snprintf(buf, sizeof(buf), ",\"s\":%d", nsindex)); } diff --git a/src/calibre/srv/tests/content.py b/src/calibre/srv/tests/content.py index 8b5dcd4c11..2cc151d77f 100644 --- a/src/calibre/srv/tests/content.py +++ b/src/calibre/srv/tests/content.py @@ -252,14 +252,14 @@ class ContentTest(LibraryBaseTest): bc = data['tree']['c'][1]['c'] self.ae(bc, body_children) - t('

at

l', [{"n":"p","s":0,"x":"a","l":"l","c":[{"s":"c","x":"c","l":"t"}]}]) - t('

a', [{"n":"p","s":0,"x":"a","a":[['class','foo'],['id','bar']]}]) + t('

at

l', [{"n":"p","x":"a","l":"l","c":[{"s":"c","x":"c","l":"t"}]}]) + t('

a', [{"n":"p","x":"a","a":[['class','foo'],['id','bar']]}]) t( '', [{'n': 'svg', 's': 1, 'a': [['href', 'h', 2]]}], ('http://www.w3.org/1999/xhtml', 'http://www.w3.org/2000/svg', 'http://www.w3.org/1999/xlink') ) text = '🐈\n\t\\mūs"' - t("

PeƱa".format(text), [{"n":"p","s":0,"x":"PeƱa","a":[['id',text]]}]) + t("

PeƱa".format(text), [{"n":"p","x":"PeƱa","a":[['id',text]]}]) text = 'a' * (127 * 1024) - t('

{0}

{0}'.format(text), [{"n":"p","s":0,"x":text}, {'n':'p','s':0,'x':text}]) + t('

{0}

{0}'.format(text), [{"n":"p","x":text}, {'n':'p','x':text}]) # }}}