From fd00c5f6982cab4f691cec261034f9875ee0ba13 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 18 Oct 2013 15:40:51 +0800 Subject: [PATCH] new escaping function for html tag attributes --- TODO | 1 - src/HTMLRenderer/general.cc | 4 ++-- src/HTMLRenderer/link.cc | 2 +- src/HTMLRenderer/outline.cc | 2 +- src/util/encoding.cc | 37 +++++++++++++++++++++++++++++++++++-- src/util/encoding.h | 15 ++++++++++----- 6 files changed, 49 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index a82de6d..d16f436 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ tmp dir: use pid -link.cc: outputURL -> outputUnicodes remove page from dom -- UI option view hash update jquery diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc index 8a4c1a0..871987f 100644 --- a/src/HTMLRenderer/general.cc +++ b/src/HTMLRenderer/general.cc @@ -212,7 +212,7 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state, XRef * xref) << "\" data-page-no=\"" << pageNum << "\" data-page-url=\""; - outputURL(f_pages.fs, cur_page_filename); + outputAttribute(f_pages.fs, cur_page_filename); f_pages.fs << "\">"; } @@ -555,7 +555,7 @@ void HTMLRenderer::embed_file(ostream & out, const string & path, const string & else { out << entry.prefix_external; - outputURL(out, fn); + outputAttribute(out, fn); out << entry.suffix_external << endl; if(copy) diff --git a/src/HTMLRenderer/link.cc b/src/HTMLRenderer/link.cc index 2607b00..a703e7f 100644 --- a/src/HTMLRenderer/link.cc +++ b/src/HTMLRenderer/link.cc @@ -195,7 +195,7 @@ void HTMLRenderer::processLink(AnnotLink * al) if(!dest_str.empty()) { (*f_curpage) << "" << "': + out << ">"; + break; + case '`': // for IE + out << "`"; + break; + default: + out << c; + } + } +} + } //namespace pdf2htmlEX diff --git a/src/util/encoding.h b/src/util/encoding.h index 900e31a..cb84b3b 100644 --- a/src/util/encoding.h +++ b/src/util/encoding.h @@ -22,15 +22,20 @@ void outputUnicodes(std::ostream & out, const Unicode * u, int uLen); /* - * URL encoding - */ -void outputURL(std::ostream & out, const std::string & s); -/* - * JSON encoding + * URL escaping */ +//void outputURL(std::ostream & out, const std::string & s); +/* + * JSON escaping + */ void outputJSON(std::ostream & out, const std::string & s); +/* + * HTML tag attribute escaping + */ +void outputAttribute(std::ostream & out, const std::string & s); + } // namespace pdf2htmlEX #endif //ENCODING_H__