Skip to content

Commit c2943bc

Browse files
committed
reworked protocol.cgi to use combinations of Write and WriteXML to
output the XML response in a compatible way that even < > characters are correctly URL encoded. This fixes #27.
1 parent 9421baa commit c2943bc

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

xmlapi/protocol.cgi

+17-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ if {[info exists sid] && [check_session $sid]} {
3030
}
3131

3232
set hm_script {
33-
string drop = "";
3433
integer iLastGroupIndex = 1;
3534
string sCollectedNames = "";
3635
string sCollectedValues = "";
@@ -57,7 +56,11 @@ if {[info exists sid] && [check_session $sid]} {
5756
if (iCount == "0") {
5857
iCount = eCount;
5958
}
60-
Write("<records start=\"" # iStart # "\" show=\"" # iCount # "\" count=\"" # eCount # "\"/>");
59+
Write("<records");
60+
Write(" start='"); WriteXML(iStart);
61+
Write("' show='"); WriteXML(iCount);
62+
Write("' count='"); WriteXML(eCount);
63+
Write("' />");
6164
}
6265

6366
append hm_script {
@@ -94,7 +97,12 @@ if {[info exists sid] && [check_session $sid]} {
9497

9598
if( iLastGroupIndex != iGroupIndex )
9699
{
97-
drop = drop # "<row datetime=\"" # sCollectedDateTimes # "\" names=\"" # sCollectedNames # "\" values=\"" # sCollectedValues # "\" timestamp=\"" # sCollectedTimestamp # "\" />\n";
100+
Write("<row");
101+
Write(" datetime='"); WriteXML(sCollectedDateTimes);
102+
Write("' names='"); WriteXML(sCollectedNames);
103+
Write("' values='"); WriteXML(sCollectedValues);
104+
Write("' timestamp='"); WriteXML(sCollectedTimestamp);
105+
Write("' />");
98106
sCollectedNames = "";
99107
sCollectedValues = "";
100108
iLastGroupIndex = iGroupIndex;
@@ -125,10 +133,13 @@ if {[info exists sid] && [check_session $sid]} {
125133
}
126134
if( sCollectedValues.Length() )
127135
{
128-
drop = drop # "<row datetime=\"" # sCollectedDateTimes # "\" names=\"" # sCollectedNames # "\" values=\"" # sCollectedValues # "\" timestamp=\"" # sCollectedTimestamp # "\" />";
136+
Write("<row");
137+
Write(" datetime='"); WriteXML(sCollectedDateTimes);
138+
Write("' names='"); WriteXML(sCollectedNames);
139+
Write("' values='"); WriteXML(sCollectedValues);
140+
Write("' timestamp='"); WriteXML(sCollectedTimestamp);
141+
Write("' />");
129142
}
130-
131-
Write(drop);
132143
}
133144
}
134145

0 commit comments

Comments
 (0)