-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Status text html escaping in wrong place #12011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/MAVLink/StatusTextHandler.cc
Outdated
void StatusTextHandler::handleTextMessage(MAV_COMPONENT compId, MAV_SEVERITY severity, const QString &text, const QString &description) | ||
{ | ||
QString htmlText(text); | ||
QString htmlText(text.toHtmlEscaped()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with escaping here is that it will be escaped twice in case of the events code path from https://github.com/mavlink/qgroundcontrol/blob/master/src/Vehicle/Vehicle.cc#L1230
That's why I originally did it outside, but did not consider that calibration was affected.
The simplest would be to add a flag as argument to indicate if it's escaped already. But I do agree, would be good to simplify this and avoid the back and forth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding from code inspection are these path(s):
- StatusTextHandler::mavlinkMessageReceived is the only thing which sucks up status text messages from mavlink
- It eventually emits StatusTextHandler::textMessageReceived
- Only connection I can find to this is on Vehicle
- Vehicle catches StatusTextHandler::textMessageReceived and calls Vehicle::_textMessageReceived which...
- Emits Vehicle::textMessageReceived
- This is unescaped status text
- This is the signal other parts of QGC like Calibration connects to
- Calls StatusTextHandler::handleTextMessage which...
- emits newErrorMessage which is escaped text
- Stuffs escaped text into the message list
- Emits Vehicle::textMessageReceived
- Events come in through Vehicle::_handleEvent - not sure how that gets called. Which then...
- Also calls StatusTextHandler::handleTextMessage
I don't see how you end up going through StatusTextHandler::handleTextMessage twice. I also don't see how to test this since I don't know how to generate an event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escaping for the events is done here:
return QString::fromStdString(str).toHtmlEscaped().toStdString(); }; |
This is because they can contain URL's which should not be escaped.
If you connect to PX4 SITL and do a takeoff you should get some events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. I get it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkueng I think I have this correct now. Can you take a look again?
- Status text coming in from events is known to already be escaped
- Regular textMessageReceived signal is not escaped
- StatusTextHandler::handleTextMessage -> StatusTextHandler::handleHTMLEscapedText name change which assumes escaped text on the way in
- Raw status text from vehicle is escaped before call to StatusTextHandler::handleHTMLEscapedText
I haven't had time to test yet. Take me a bit to get a SITL setup to work again on OSX arm.
For me it works the same good, as in the #11990. Tested all the ways I know and use the QGC, nothing broke. But, for the history, I will remind you that we decided to fix the signals the other way. |
Regular status text messages should move around system un-formatted Add missing textMessageReceived signaling
8bc1301
to
6200b34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this looks correct
This is a replacement for #11990. I was crazy hard to get my head around all the back and forth of status text between vehicle and StatusTextHandler. So I created the most minimal set of changes I could come up with to fix the problem. I tested it and it works as far as I can tell.
The basic idea is that status text which flows through the system should not be html escaped until the very last place when it needs to be output to a rich text control. This is critical vehicle error popups and the message indicator dropdown. Status text which flows from Vehicle should raw for people connecting to that signaling.
@stepan14511 Can you test as well.