Skip to content
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

fix: Fixed IPv6 validation #5574

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.Objects;
import java.util.Optional;
import java.util.logging.Logger;

import org.eclipse.kura.web.client.messages.Messages;
import org.eclipse.kura.web.client.util.HelpButton;
Expand Down Expand Up @@ -163,6 +164,7 @@ interface TabIp6UiUiBinder extends UiBinder<Widget, TabIp6Ui> {

private static TabIp6UiUiBinder uiBinder = GWT.create(TabIp6UiUiBinder.class);
private static final Messages MSGS = GWT.create(Messages.class);
private static final Logger logger = Logger.getLogger(TabIp6Ui.class.getSimpleName());

private boolean dirty = false;
private final NetworkTabsUi tabs;
Expand Down Expand Up @@ -372,12 +374,12 @@ private void initIpField() {
boolean isValid = address != null && address.trim().length() > 0
&& address.trim().matches(IPV6_ADDRESS_REGEX);

if (!isValid) {
this.groupIp.setValidationState(ValidationState.ERROR);
this.wrongInputIp.setText(MSGS.netIPv6InvalidAddress());
} else {
if (isValid) {
this.groupIp.setValidationState(ValidationState.NONE);
this.wrongInputIp.setText("");
} else {
this.groupIp.setValidationState(ValidationState.ERROR);
this.wrongInputIp.setText(MSGS.netIPv6InvalidAddress());
}
});
}
Expand Down Expand Up @@ -660,16 +662,20 @@ private boolean nullOrEmpty(String value) {
public boolean isValid() {
boolean isWan = this.status.getSelectedValue().equals(STATUS_WAN);
boolean isManual = this.configure.getSelectedValue().equals(CONFIGURE_MANUAL);
boolean isValid = true;

if (isWan && isManual) {
if (nullOrEmpty(this.ip.getValue()) || this.subnet.getValue() == null
|| nullOrEmpty(this.gateway.getValue())) {
if (isManual) {
if (nullOrEmpty(this.ip.getValue()) || this.subnet.getValue() == null) {
this.groupIp.setValidationState(ValidationState.ERROR);
this.groupSubnet.setValidationState(ValidationState.ERROR);
this.groupGateway.setValidationState(ValidationState.ERROR);
this.wrongInputIp.setText(MSGS.netIPv6InvalidAddress());
this.wrongInputSubnet.setText(MSGS.netIpv6InvalidSubnet());
isValid = false;
}
if (isWan && nullOrEmpty(this.gateway.getValue())) {
this.groupGateway.setValidationState(ValidationState.ERROR);
this.wrongInputGateway.setText(MSGS.netIPv6InvalidAddress());
return false;
isValid = false;
}
}

Expand All @@ -678,10 +684,10 @@ public boolean isValid() {
|| this.groupSubnet.getValidationState().equals(ValidationState.ERROR)
|| this.groupGateway.getValidationState().equals(ValidationState.ERROR)
|| this.groupDns.getValidationState().equals(ValidationState.ERROR)) {
return false;
isValid = false;
}

return true;
return isValid;
}

@Override
Expand Down
Loading