lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 1d99e76 008/156: Make pdf_writer_wx::output_h


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 1d99e76 008/156: Make pdf_writer_wx::output_html() type safe by taking html::text
Date: Tue, 30 Jan 2018 17:21:50 -0500 (EST)

branch: master
commit 1d99e761fe208c0382515c99eb98e41616b6488a
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Make pdf_writer_wx::output_html() type safe by taking html::text
    
    Accept html::text which is guaranteed to be correctly escaped, by
    construction, rather than arbitrary strings.
---
 group_quote_pdf_gen_wx.cpp | 6 +++---
 pdf_writer_wx.cpp          | 6 ++++--
 pdf_writer_wx.hpp          | 4 +++-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index 66ba8f1..42b659c 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -945,7 +945,7 @@ void group_quote_pdf_generator_wx::output_document_header
         (pdf_writer.get_horz_margin()
         ,*pos_y
         ,pdf_writer.get_page_width() / 2
-        ,title_html.as_html()
+        ,title_html
         );
 
     // Build the summary table with all the mandatory fields, starting by
@@ -1020,7 +1020,7 @@ void group_quote_pdf_generator_wx::output_document_header
         (pdf_writer.get_horz_margin() + pdf_writer.get_page_width() / 2
         ,*pos_y
         ,pdf_writer.get_page_width() / 2
-        ,summary_html.as_html()
+        ,summary_html
         );
 
     // wxHTML tables don't support "frame" attribute, so draw the border around
@@ -1201,7 +1201,7 @@ void group_quote_pdf_generator_wx::output_footer
         (pdf_writer.get_horz_margin()
         ,*pos_y
         ,pdf_writer.get_page_width()
-        ,footer_html.as_html()
+        ,footer_html
         ,output_mode
         );
 }
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index 72d8105..1190a4d 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -24,6 +24,7 @@
 #include "pdf_writer_wx.hpp"
 
 #include "alert.hpp"
+#include "html.hpp"
 
 #include <wx/html/htmlcell.h>
 
@@ -140,12 +141,13 @@ int pdf_writer_wx::output_html
     (int x
     ,int y
     ,int width
-    ,wxString const& html
+    ,html::text const& html
     ,enum_output_mode output_mode
     )
 {
+    auto const html_str = wxString::FromUTF8(html.as_html());
     std::unique_ptr<wxHtmlContainerCell> const cell
-        (static_cast<wxHtmlContainerCell*>(html_parser_.Parse(html))
+        (static_cast<wxHtmlContainerCell*>(html_parser_.Parse(html_str))
         );
     LMI_ASSERT(cell);
 
diff --git a/pdf_writer_wx.hpp b/pdf_writer_wx.hpp
index fff8a53..21fccb0 100644
--- a/pdf_writer_wx.hpp
+++ b/pdf_writer_wx.hpp
@@ -32,6 +32,8 @@
 
 #include <memory>                       // std::unique_ptr
 
+namespace html { class text; }
+
 enum enum_output_mode
     {e_output_normal
     ,e_output_measure_only
@@ -55,7 +57,7 @@ class pdf_writer_wx
         (int x
         ,int y
         ,int width
-        ,wxString const& html
+        ,html::text const& html
         ,enum_output_mode output_mode = e_output_normal
         );
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]