Closed knro closed 3 years ago
All escape should be done when converting to XML and from XML. Unfortunately, this has not been done from the beginning and is now problematic. Now you have to make hotfixes that will solve and create new problems (if you want, I can describe it).
I'll be making fixes tonight.
My suspicions have been confirmed.
I quickly renamed the button in the example to "Control Rain <FAIL>"
.
bool RainDetector::initProperties()
{
// Must init parent properties first!
INDI::DefaultDevice::initProperties();
IUFillLight(&RainL[0], "Status", "", IPS_IDLE);
IUFillLightVector(&RainLP, RainL, 1, getDeviceName(), "Rain Alert", "", MAIN_CONTROL_TAB, IPS_IDLE);
IUFillSwitch(&RainS[0], "On", "", ISS_OFF);
IUFillSwitch(&RainS[1], "Off", "", ISS_OFF);
IUFillSwitchVector(&RainSP, RainS, 2, getDeviceName(), "Control Rain <FAIL>", "", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 0,
IPS_IDLE);
return true;
}
2021-04-03T19:54:11: Driver ./tutorial_rain: tutorial_rain dispatch error: Property Control Rain <FAIL> is not defined in Rain Detector.
The structure holds the text "Control Rain <FAIL>"
.
I can move the use of the escape function where XML is built. We'll see what happens.
Edit: baseclient.cpp and baseclientqt.cpp are also bugged.
Edit: devicemanager.cpp in kstars also...
KStars has double unescap?
void escapeXML_fputs(const char *src, FILE *stream);
void escapeXML_vprintf(const char *fmt, va_list ap);
void escapeXML_vfprintf(FILE *stream, const char *fmt, va_list ap);
#define prints(STR) fputs(STR, stdout)
#define printsx(STR) escapeXML_fputs(STR, stdout)
#define printfx(...) escapeXML_vfprintf(stdout, __VA_ARGS__)
What's going on here?!
I need to double check but perhaps QLabel is interpreting the text as such? Maybe it's a Qt thing.
This is not a QT problem. I improved the INDI library and recompiled KStars. It looks okay now.
I just ran across an issue whereas the initial text needs to be escaped (It was from DSLR camera, so dynamic). IUFillText escapes name and label, but not initial text
https://github.com/indilib/indi/blob/bd9110b4a35f6848ad7880d7b74cae7c3a79bbfc/indidriver.c#L504
I thought about replacing it with this:
Do you think this is sufficient? is there a better way to do it?