-
Notifications
You must be signed in to change notification settings - Fork 29
fix: Fix dconfig input text not conforming to JSON standards #144
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -734,6 +734,11 @@ void KeyContent::setBaseInfo(ConfigGetter *getter, const QString &language) | |||||||||||||||||||||
| auto widget = new DLineEdit(this); | ||||||||||||||||||||||
| widget->setEnabled(canWrite); | ||||||||||||||||||||||
| connect(widget, &DLineEdit::editingFinished, widget, [this, widget](){ | ||||||||||||||||||||||
| QString errorMsg; | ||||||||||||||||||||||
| if (!validateTextInput(widget->text(), errorMsg)) { | ||||||||||||||||||||||
| qWarning() << errorMsg; | ||||||||||||||||||||||
|
||||||||||||||||||||||
| qWarning() << errorMsg; | |
| qWarning() << errorMsg; | |
| const QString message = errorMsg.isEmpty() | |
| ? tr("The entered value is invalid.") | |
| : errorMsg; | |
| QMessageBox::warning(widget, | |
| tr("Invalid input"), | |
| message); | |
| widget->setFocus(); | |
| widget->selectAll(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -391,7 +391,13 @@ QWidget *OEMDialog::getItemWidget(ConfigGetter *getter, DStandardItem *item) | |
| auto widget = new DLineEdit(); | ||
| widget->setText(qvariantToString(v)); | ||
| widget->setEnabled(canWrite); | ||
| connect(widget, &DLineEdit::textChanged, widget, [this, item](const QString &text){ | ||
| connect(widget, &DLineEdit::editingFinished, widget, [this, widget, item](){ | ||
| QString text = widget->text(); | ||
| QString errorMsg; | ||
| if (!validateTextInput(text, errorMsg)) { | ||
| qWarning() << errorMsg; | ||
| return; | ||
| } | ||
|
Comment on lines
+397
to
+400
|
||
| item->setData(stringToQVariant(text), ValueRole); | ||
| treeItemChanged(item); | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -292,6 +292,11 @@ int CommandManager::setCommand() | |||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| manager->setValue(key, value.toDouble()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| QString errorMsg; | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (!validateTextInput(value, errorMsg)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| outpuSTDError(errorMsg); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| manager->setValue(key, stringToQVariant(value)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+296
to
300
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (!validateTextInput(value, errorMsg)) { | |
| outpuSTDError(errorMsg); | |
| return 1; | |
| } | |
| manager->setValue(key, stringToQVariant(value)); | |
| QString sanitizedValue = value; | |
| if (!validateTextInput(sanitizedValue, errorMsg)) { | |
| // If validation fails, try again after stripping surrounding quotes (e.g. "foo" -> foo) | |
| const int len = sanitizedValue.size(); | |
| if (len >= 2 && sanitizedValue.startsWith(QLatin1Char('"')) && sanitizedValue.endsWith(QLatin1Char('"'))) { | |
| QString unquoted = sanitizedValue.mid(1, len - 2); | |
| errorMsg.clear(); | |
| if (!validateTextInput(unquoted, errorMsg)) { | |
| outpuSTDError(errorMsg); | |
| return 1; | |
| } | |
| sanitizedValue = unquoted; | |
| } else { | |
| outpuSTDError(errorMsg); | |
| return 1; | |
| } | |
| } | |
| manager->setValue(key, stringToQVariant(sanitizedValue)); |
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.
这个可能溢出吧,