Commit b7daee75 authored by hexchain's avatar hexchain Committed by Jan Grulich

wireguard: Trim IP list before submitting to NM

The `SimpleIpListValidator` validates each trimmed item in a comma-separated
list, but `WireGuardPeerWidget` sets `peerData` without trimming each item.
Untrimmed items are not accepted by NetworkManager, so the user might see NM
rejecting values that are valid in the peer settings dialog.

Fix this discrepancy by trimming each item before setting `peerData`.

Test Plan:
1. Type a comma-separated list of IP addresses, with spaces around comma, into
the "Allowed IPs" field of the WireGuard peer settings dialog.

2. Save the connection. No error should be reported by NM.

Reviewers: jgrulich

Reviewed By: jgrulich

Subscribers: usta, plasma-devel

Tags: #plasma

Differential Revision:
parent 764cb342
......@@ -186,10 +186,17 @@ void WireGuardPeerWidget::checkAllowedIpsValid()
int pos = 0;
QLineEdit *widget = d->ui.allowedIPsLineEdit;
QString ipString = widget->displayText();
QStringList ipList = ipString.split(',');
QStringList rawIPList = ipString.split(',');
QStringList ipList;
bool valid = QValidator::Acceptable == allowedIPsValidator.validate(ipString, pos);
setBackground(widget, valid);
for (const QString &ip : rawIPList) {
d->peerData[PNM_WG_PEER_KEY_ALLOWED_IPS] = ipList;
if (valid != d->allowedIPsValid) {
d->allowedIPsValid = valid;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment