fix(browser): Fix favorite entries for malformed and long names
Limit long named tabs Also avoid breaking visualization by escaping HTML fix: #4961
This commit is contained in:
parent
e5322276ec
commit
c03cdef684
|
@ -32,7 +32,9 @@ RowLayout {
|
|||
icon.source: imageUrl
|
||||
icon.width: 24
|
||||
icon.height: 24
|
||||
text: name
|
||||
// Limit long named tabs. StatusFlatButton is not well-behaved control
|
||||
// implicitWidth doesn't work. Also avoid breaking visualization by escaping HTML
|
||||
text: Utils.escapeHtml(Utils.elideIfTooLong(name, 40))
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -697,6 +697,20 @@ QtObject {
|
|||
return qsTr("now")
|
||||
}
|
||||
|
||||
function elideIfTooLong(str, maxLength) {
|
||||
return (str.length > maxLength) ? str.substr(0, maxLength-4) + '...' : str;
|
||||
}
|
||||
|
||||
function escapeHtml(unsafeStr)
|
||||
{
|
||||
return unsafeStr
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
// Leave this function at the bottom of the file as QT Creator messes up the code color after this
|
||||
function isPunct(c) {
|
||||
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|_|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
||||
|
|
Loading…
Reference in New Issue