@@ -32,6 +32,11 @@ QgsPythonDialog::~QgsPythonDialog()
32
32
QgsPythonUtils::uninstallConsoleHooks ();
33
33
}
34
34
35
+ QString QgsPythonDialog::escapeHtml (QString text)
36
+ {
37
+ return text.replace (" <" ," <" ).replace (" >" ," >" );
38
+ }
39
+
35
40
void QgsPythonDialog::on_edtCmdLine_returnPressed ()
36
41
{
37
42
QString command = edtCmdLine->text ();
@@ -43,12 +48,10 @@ void QgsPythonDialog::on_edtCmdLine_returnPressed()
43
48
{
44
49
QgsPythonUtils::evalString (" sys.stdout.data" , output);
45
50
QgsPythonUtils::runString (" sys.stdout.data = ''" );
46
- QString result = QgsPythonUtils::getResult ();
51
+ QString result = QgsPythonUtils::getResult ();
47
52
// escape the result so python objects display properly and
48
53
// we can still use html output to get nicely formatted display
49
- result.replace (" <" ," <" );
50
- result.replace (" >" ," >" );
51
- output += result;
54
+ output = escapeHtml (output) + escapeHtml (result);
52
55
53
56
if (!output.isEmpty ())
54
57
output += " <br>" ;
@@ -58,10 +61,10 @@ void QgsPythonDialog::on_edtCmdLine_returnPressed()
58
61
QString className, errorText;
59
62
QgsPythonUtils::getError (className, errorText);
60
63
61
- output = " <font color=\" red\" >" + className + " : " + errorText + " </font><br>" ;
64
+ output = " <font color=\" red\" >" + escapeHtml ( className) + " : " + escapeHtml ( errorText) + " </font><br>" ;
62
65
}
63
66
64
- QString str = " <b><font color=\" green\" >>>></font> " + command. replace ( " < " , " < " ) + " </b><br>" + output;
67
+ QString str = " <b><font color=\" green\" >>>></font> " + escapeHtml (command ) + " </b><br>" + output;
65
68
txtHistory->setText (txtHistory->text () + str);
66
69
edtCmdLine->setText (" " );
67
70
0 commit comments