Skip to content

Commit

Permalink
The other places I found that cause problems if we don't validate the…
Browse files Browse the repository at this point in the history
… configuration we read.
  • Loading branch information
gunterkoenigsmann committed Feb 23, 2023
1 parent 25fd3a9 commit 82b190b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,10 @@ void Configuration::ReadConfig() {
{
int tmp = static_cast<int>(m_htmlEquationFormat);
config->Read("HTMLequationFormat", &tmp);
if(tmp < 0)
tmp = mathJaX_TeX;
if(tmp > html_export_invalidChoice)
tmp = svg;
m_htmlEquationFormat = static_cast<Configuration::htmlExportFormat>(tmp);
}

Expand All @@ -764,12 +768,20 @@ void Configuration::ReadConfig() {
config->Read(wxT("useUnicodeMaths"), &m_useUnicodeMaths);
config->Read(wxT("mathJaxURL"), &m_mathJaxURL);
config->Read(wxT("autosubscript"), &m_autoSubscript);
if(m_autoSubscript < 0)
m_autoSubscript = 0;
if(m_autoSubscript > 2)
m_autoSubscript = 2;
config->Read(wxT("antiAliasLines"), &m_antiAliasLines);
config->Read(wxT("indentMaths"), &m_indentMaths);
config->Read(wxT("abortOnError"), &m_abortOnError);
config->Read("defaultPort", &m_defaultPort);
config->Read(wxT("fixReorderedIndices"), &m_fixReorderedIndices);
config->Read(wxT("showLength"), &m_showLength);
if(m_showLength < 0)
m_showLength = 0;
if(m_showLength > 3)
m_showLength = 3;
config->Read(wxT("printScale"), &m_printScale);
config->Read(wxT("useSVG"), &m_useSVG);
config->Read(wxT("copyBitmap"), &m_copyBitmap);
Expand All @@ -793,6 +805,10 @@ void Configuration::ReadConfig() {
config->Read(wxT("autoIndent"), &m_autoIndent);

long showLabelChoice = static_cast<long>(m_showLabelChoice);
if(static_cast<long>(m_showLabelChoice) < 0)
m_showLabelChoice = labels_automatic;
if(m_showLabelChoice >= labels_invalidSelection)
m_showLabelChoice = labels_none;
config->Read(wxT("showLabelChoice"), &showLabelChoice);
m_showLabelChoice = (showLabels)showLabelChoice;

Expand Down
6 changes: 4 additions & 2 deletions src/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,17 @@ class Configuration
mathJaX_TeX = 0,
bitmap = 1,
mathML_mathJaX = 2,
svg = 3
svg = 3,
html_export_invalidChoice
};

enum showLabels : int8_t
{
labels_automatic = 0,
labels_prefer_user = 1,
labels_useronly = 2,
labels_none = 3
labels_none = 3,
labels_invalidSelection
};

enum drawMode
Expand Down

0 comments on commit 82b190b

Please sign in to comment.