Skip to content

Commit

Permalink
Strip html tags from window title and completion dialog
Browse files Browse the repository at this point in the history
These are native controls that can't contain html
  • Loading branch information
mrichards42 committed May 7, 2024
1 parent 085eca5 commit 8c315af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,7 @@ MyFrame::ShowMetadata()
SetTitle(XWORD_APP_NAME);
else {
// Puzzle titles can contain HTML, so parse out the plain text.
PlainTextHtmlParser parser;
wxString title = * (wxString*) (parser.Parse(puz2wx(m_puz.GetTitle())));
wxString title = PlainTextHtmlParser::StripTags(puz2wx(m_puz.GetTitle()));
SetTitle(title + _T(" - ") XWORD_APP_NAME);
}

Expand Down Expand Up @@ -1095,8 +1094,10 @@ MyFrame::CheckPuzzle()
m_status->SetAlert(_T("The puzzle is filled correctly!"),
wxGetApp().GetConfigManager().Status.completeColor());
// Show completion message for acrostics since it is often the formatted quote.
if (m_puz.GetGrid().IsAcrostic() && m_puz.HasMeta(puzT("completion")))
XWordMessage(this, m_puz.GetMeta(puzT("completion")));
if (m_puz.GetGrid().IsAcrostic() && m_puz.HasMeta(puzT("completion"))) {
wxString message = PlainTextHtmlParser::StripTags(puz2wx(m_puz.GetMeta(puzT("completion"))));
XWordMessage(this, message);
}
break;
case UNCHECKABLE_PUZZLE:
StopTimer();
Expand Down
6 changes: 6 additions & 0 deletions src/html/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class PlainTextHtmlParser : public wxHtmlParser
return (wxObject*) &text;
}

static wxString StripTags (const wxString & input) {
PlainTextHtmlParser parser;
wxString text = * (wxString*) parser.Parse(input);
return text;
}

private:
wxString text;
};

0 comments on commit 8c315af

Please sign in to comment.