Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24286/src/modules
Modified Files:
HtmlViewer.cpp
Log Message:
fixed bug with showing garbage if attachment or image name or label contained double
quotes (happened all the time with PGP/GPG icons)
Index: HtmlViewer.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/HtmlViewer.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -b -u -2 -r1.62 -r1.63
--- HtmlViewer.cpp 27 Apr 2004 11:26:16 -0000 1.62
+++ HtmlViewer.cpp 16 May 2004 13:08:23 -0000 1.63
@@ -58,4 +58,9 @@
static wxString MakeHtmlSafe(const wxString& text);
+// escape all double quotes in a string by replacing them with HTML entity
+//
+// this is useful for the HTML attributes values
+static wxString EscapeQuotes(const wxString& text);
+
// ----------------------------------------------------------------------------
// HtmlViewer: a wxHTML-based MessageViewer implementation
@@ -772,4 +777,20 @@
}
+static wxString EscapeQuotes(const wxString& text)
+{
+ wxString textSafe;
+ textSafe.reserve(text.length());
+
+ for ( const wxChar *p = text.c_str(); *p; p++ )
+ {
+ if ( *p == '"' )
+ textSafe += _T(""");
+ else
+ textSafe += *p;
+ }
+
+ return textSafe;
+}
+
void HtmlViewer::AddColourAttr(const wxChar *attr, const wxColour& col)
{
@@ -934,5 +955,5 @@
m_htmlText << _T("</td><td width=")
<< wxString::Format(_T("%d"), m_bmpXFace.GetWidth()) << _T(">")
- _T("<img src=\"memory:") << filename << _T("\">"
+ _T("<img src=\"memory:") << EscapeQuotes(filename) << _T("\">"
"</td>"
"</table>");
@@ -974,6 +995,6 @@
m_htmlText << _T("<a href=\"") << url << _T("\">"
- "<img alt=\"") << ci->GetLabel() << _T("\" src=\"") << url
- << _T("\"></a>");
+ "<img alt=\"") << EscapeQuotes(ci->GetLabel())
+ << _T("\" src=\"") << url << _T("\"></a>");
m_window->StoreClickable(ci, url);
@@ -993,6 +1014,6 @@
m_htmlText << _T("<a href=\"") << url << _T("\">"
- "<p><img alt=\"") << ci->GetLabel() << _T("\" "
- "src=\"") << url << _T("\"></a>");
+ "<p><img alt=\"") << EscapeQuotes(ci->GetLabel())
+ << _T("\" src=\"") << url << _T("\"></a>");
m_window->StoreClickable(ci, url);
-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates