Skip to content

Commit 6e1faff

Browse files
committed
issue doxygen#11415 doxywizard replaces < and > in aliases with &lt; / &gt;
We have to distinguish for writing of the settings between - writing to the, HTML, doxywizard "console" - writing to file / pipe to run doxygen In the first case characters like `<` have to be escaped, in the second case this should not happen. This is actually a regression on: ``` Commit: d3d0a1d [d3d0a1d] Date: Thursday, January 2, 2025 4:00:17 PM String representation at "show configuration" in doxywizard In case a string in the settings contains a `<` / `>` / `&` this can give strange results as they are literally interpreted but should be escaped. (issue is a side note to issue doxygen#11310) ```
1 parent 8add458 commit 6e1faff

File tree

15 files changed

+46
-32
lines changed

15 files changed

+46
-32
lines changed

addon/doxywizard/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bool parseConfig(
2626
const QHash<QString,Input *> &options
2727
);
2828

29-
void writeStringValue(QTextStream &t,TextCodecAdapter *codec,const QString &s);
29+
void writeStringValue(QTextStream &t,TextCodecAdapter *codec,const QString &s,bool convert);
3030

3131
// directly copied from ../../src/config.h to be consistent
3232
enum

addon/doxywizard/config_doxyw.l

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ bool parseConfig(
785785
return true;
786786
}
787787

788-
void writeStringValue(QTextStream &t,TextCodecAdapter *codec,const QString &s)
788+
void writeStringValue(QTextStream &t,TextCodecAdapter *codec,const QString &s,bool convert)
789789
{
790790
QChar c;
791791
bool needsEscaping=false;
@@ -823,10 +823,17 @@ void writeStringValue(QTextStream &t,TextCodecAdapter *codec,const QString &s)
823823
if (*p ==QChar::fromLatin1(' ') &&
824824
*(p+1)==QChar::fromLatin1('\0')) break; // skip inserted space at the end
825825
if (*p ==QChar::fromLatin1('"')) t << "\\"; // escape quotes
826-
if (*p ==QChar::fromLatin1('<')) t << "&lt;";
827-
else if (*p ==QChar::fromLatin1('>')) t << "&gt;";
828-
else if (*p ==QChar::fromLatin1('&')) t << "&amp;";
829-
else t << *p;
826+
if (convert)
827+
{
828+
if (*p ==QChar::fromLatin1('<')) t << "&lt;";
829+
else if (*p ==QChar::fromLatin1('>')) t << "&gt;";
830+
else if (*p ==QChar::fromLatin1('&')) t << "&amp;";
831+
else t << *p;
832+
}
833+
else
834+
{
835+
t << *p;
836+
}
830837
p++;
831838
}
832839
}
@@ -835,10 +842,17 @@ void writeStringValue(QTextStream &t,TextCodecAdapter *codec,const QString &s)
835842
p=s.data();
836843
while (!p->isNull())
837844
{
838-
if (*p ==QChar::fromLatin1('<')) t << "&lt;";
839-
else if (*p ==QChar::fromLatin1('>')) t << "&gt;";
840-
else if (*p ==QChar::fromLatin1('&')) t << "&amp;";
841-
else t << *p;
845+
if (convert)
846+
{
847+
if (*p ==QChar::fromLatin1('<')) t << "&lt;";
848+
else if (*p ==QChar::fromLatin1('>')) t << "&gt;";
849+
else if (*p ==QChar::fromLatin1('&')) t << "&amp;";
850+
else t << *p;
851+
}
852+
else
853+
{
854+
t << *p;
855+
}
842856
p++;
843857
}
844858
}

addon/doxywizard/doxywizard.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ void MainWindow::saveConfig(const QString &fileName)
341341
}
342342
QTextStream t(&f);
343343
t.device()->setTextModeEnabled(false);
344-
m_expert->writeConfig(t,false,false);
344+
m_expert->writeConfig(t,false,false,false);
345345
updateConfigFileName(fileName);
346346
m_modified = false;
347347
updateTitle();
@@ -586,7 +586,7 @@ void MainWindow::runDoxygen()
586586
return;
587587
}
588588
QTextStream t(m_runProcess);
589-
m_expert->writeConfig(t,false,false);
589+
m_expert->writeConfig(t,false,false,false);
590590
t.flush();
591591
m_runProcess->closeWriteChannel();
592592

@@ -718,11 +718,11 @@ void MainWindow::showSettings()
718718
QTextStream t(&text);
719719
if (m_showCondensedSettings->isChecked())
720720
{
721-
m_expert->writeConfig(t,true,true);
721+
m_expert->writeConfig(t,true,true,true);
722722
}
723723
else
724724
{
725-
m_expert->writeConfig(t,true,false);
725+
m_expert->writeConfig(t,true,false,true);
726726
}
727727
m_outputLog->clear();
728728
m_outputLog->append(APPQT(text));

addon/doxywizard/expert.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ void Expert::loadConfig(const QString &fileName)
791791
}
792792

793793
void Expert::saveTopic(QTextStream &t,QDomElement &elem,TextCodecAdapter *codec,
794-
bool brief,bool condensed)
794+
bool brief,bool condensed,bool convert)
795795
{
796796
if (!brief)
797797
{
@@ -832,7 +832,7 @@ void Expert::saveTopic(QTextStream &t,QDomElement &elem,TextCodecAdapter *codec,
832832
if (option && !option->isEmpty())
833833
{
834834
t << " ";
835-
option->writeValue(t,codec);
835+
option->writeValue(t,codec,convert);
836836
}
837837
t << "\n";
838838
}
@@ -843,7 +843,7 @@ void Expert::saveTopic(QTextStream &t,QDomElement &elem,TextCodecAdapter *codec,
843843
}
844844
}
845845

846-
bool Expert::writeConfig(QTextStream &t,bool brief, bool condensed)
846+
bool Expert::writeConfig(QTextStream &t,bool brief, bool condensed, bool convert)
847847
{
848848
// write global header
849849
t << "# Doxyfile " << getDoxygenVersion().c_str() << "\n\n";
@@ -859,7 +859,7 @@ bool Expert::writeConfig(QTextStream &t,bool brief, bool condensed)
859859
{
860860
if (childElem.tagName()==SA("group"))
861861
{
862-
saveTopic(t,childElem,&codec,brief,condensed);
862+
saveTopic(t,childElem,&codec,brief,condensed,convert);
863863
}
864864
childElem = childElem.nextSiblingElement();
865865
}

addon/doxywizard/expert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Expert : public QSplitter, public DocIntf
3838
void loadSettings(QSettings *);
3939
void saveSettings(QSettings *);
4040
void loadConfig(const QString &fileName);
41-
bool writeConfig(QTextStream &t,bool brief,bool condensed);
41+
bool writeConfig(QTextStream &t,bool brief,bool condensed, bool convert);
4242
QByteArray saveInnerState () const;
4343
bool restoreInnerState ( const QByteArray & state );
4444
const QHash<QString,Input*> &modelData() const { return m_options; }
@@ -67,7 +67,7 @@ class Expert : public QSplitter, public DocIntf
6767

6868
private:
6969
void createTopics(const QDomElement &);
70-
void saveTopic(QTextStream &t,QDomElement &elem,TextCodecAdapter *codec,bool brief,bool dondensed);
70+
void saveTopic(QTextStream &t,QDomElement &elem,TextCodecAdapter *codec,bool brief,bool dondensed,bool convert);
7171

7272
QSplitter *m_splitter;
7373
QTextBrowser *m_helper;

addon/doxywizard/input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Input
4242
virtual void updateDependencies() = 0;
4343
virtual void reset() = 0;
4444
virtual bool isDefault() = 0;
45-
virtual void writeValue(QTextStream &t,TextCodecAdapter *codec) = 0;
45+
virtual void writeValue(QTextStream &t,TextCodecAdapter *codec,bool convert) = 0;
4646
virtual void setTemplateDocs(const QString &docs) = 0;
4747
virtual bool isEmpty() { return false; };
4848
};

addon/doxywizard/inputbool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void InputBool::reset()
134134
setValue(m_default);
135135
}
136136

137-
void InputBool::writeValue(QTextStream &t,TextCodecAdapter *codec)
137+
void InputBool::writeValue(QTextStream &t,TextCodecAdapter *codec,bool)
138138
{
139139
if (m_state)
140140
t << codec->encode(QString::fromLatin1("YES"));

addon/doxywizard/inputbool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class InputBool : public QObject, public Input
3939
void setEnabled(bool);
4040
void updateDependencies();
4141
bool isDefault();
42-
void writeValue(QTextStream &t,TextCodecAdapter *codec);
42+
void writeValue(QTextStream &t,TextCodecAdapter *codec,bool convert);
4343
void setTemplateDocs(const QString &docs) { m_tdocs = docs; }
4444
static bool convertToBool(const QVariant &v,bool &isValid);
4545

addon/doxywizard/inputint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void InputInt::reset()
123123
setValue(m_default);
124124
}
125125

126-
void InputInt::writeValue(QTextStream &t,TextCodecAdapter *)
126+
void InputInt::writeValue(QTextStream &t,TextCodecAdapter *,bool)
127127
{
128128
t << m_val;
129129
}

addon/doxywizard/inputint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class InputInt : public QObject, public Input
4242
void setEnabled(bool);
4343
void updateDependencies() {}
4444
bool isDefault();
45-
void writeValue(QTextStream &t,TextCodecAdapter *codec);
45+
void writeValue(QTextStream &t,TextCodecAdapter *codec,bool convert);
4646
void setTemplateDocs(const QString &docs) { m_tdocs = docs; }
4747

4848
public slots:

0 commit comments

Comments
 (0)