X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bb5b214dabf462aabd35094ffbf217cb060c8a59..2bc44d6257f74b7f815d4a44014717b21dc20fd5:/src/richtext/richtextxml.cpp?ds=inline diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index c09d334297..74d6bbf9d7 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -23,6 +23,7 @@ #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/module.h" + #include "wx/log.h" #endif #include "wx/filename.h" @@ -172,10 +173,18 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node) } else if (childName == wxT("image")) { - int imageType = wxBITMAP_TYPE_PNG; + wxBitmapType imageType = wxBITMAP_TYPE_PNG; wxString value = node->GetAttribute(wxT("imagetype"), wxEmptyString); if (!value.empty()) - imageType = wxAtoi(value); + { + int type = wxAtoi(value); + + // note: 0 == wxBITMAP_TYPE_INVALID + if (type <= 0 || type >= wxBITMAP_TYPE_MAX) + wxLogWarning("Invalid bitmap type specified for tag: %d", type); + else + imageType = (wxBitmapType)type; + } wxString data; @@ -718,7 +727,7 @@ bool wxRichTextXMLHandler::ExportXML(wxOutputStream& stream, wxMBConv* convMem, else for (i = 0; i < len; i++) { int c = (int) text[i]; - if (c < 32 && c != 9 && c != 10 && c != 13) + if ((c < 32 || c == 34) && c != 9 && c != 10 && c != 13) { if (i > 0) {