fix(@desktop/communities): enforce alphanumerical characters in community name, description, channel name

This commit is contained in:
mprakhov 2023-01-27 02:12:48 +02:00 committed by Mykhailo Prakhov
parent 3c4d97248e
commit 44cc6bbf83
6 changed files with 24 additions and 1 deletions

View File

@ -26,6 +26,10 @@ StatusInput {
minLength: 1
errorMessage: Utils.getErrorMessage(root.errors,
qsTr("community description"))
},
StatusRegularExpressionValidator {
regularExpression: Constants.regularExpressions.alphanumericalExpanded
errorMessage: Constants.errorMessages.alphanumericalExpandedRegExp
}
]
}

View File

@ -13,11 +13,16 @@ StatusInput {
label: qsTr("Name your community")
charLimit: 30
placeholderText: qsTr("A catchy name")
validators: [
StatusMinLengthValidator {
minLength: 1
errorMessage: Utils.getErrorMessage(root.errors,
qsTr("community name"))
},
StatusRegularExpressionValidator {
regularExpression: Constants.regularExpressions.alphanumericalExpanded
errorMessage: Constants.errorMessages.alphanumericalExpandedRegExp
}
]
}

View File

@ -46,7 +46,8 @@ StatusScrollView {
property size bottomReservedSpace: Qt.size(0, 0)
property bool bottomReservedSpaceActive: false
readonly property bool saveChangesButtonEnabled: true
readonly property bool saveChangesButtonEnabled: !((nameInput.input.dirty && !nameInput.valid) ||
(descriptionTextInput.input.dirty && !descriptionTextInput.valid))
ColumnLayout {
id: layout

View File

@ -135,6 +135,10 @@ StatusDialog {
StatusMinLengthValidator {
minLength: 1
errorMessage: Utils.getErrorMessage(nameInput.errors, qsTr("channel name"))
},
StatusRegularExpressionValidator {
regularExpression: Constants.regularExpressions.alphanumericalExpanded
errorMessage: Constants.errorMessages.alphanumericalExpandedRegExp
}
]
}

View File

@ -18,6 +18,7 @@ StatusScrollView {
objectName: "communityColorPanelSelectColorButton"
text: qsTr("Select Community Colour")
onClicked: root.accepted()
enabled: hexInput.valid
}
property alias color: colorSpace.color

View File

@ -578,6 +578,14 @@ QtObject {
readonly property int telegram: 6
}
readonly property QtObject regularExpressions: QtObject {
readonly property var alphanumericalExpanded: /^$|^[a-zA-Z0-9\-_ ]+$/
}
readonly property QtObject errorMessages: QtObject {
readonly property string alphanumericalExpandedRegExp: qsTr("Only letters, numbers, underscores, whitespaces and hyphens allowed")
}
readonly property var socialLinkPrefixesByType: [ // NB order must match the "socialLinkType" enum above
"",
"https://twitter.com/",