From 8d078090603888e0933a036c0982e6961b41d205 Mon Sep 17 00:00:00 2001 From: caixiangrong Date: Mon, 30 Dec 2024 13:33:26 +0800 Subject: [PATCH] fix: IPv6 regular expression error IPv6 regular expression error pms: BUG-286743 --- dcc-network/qml/NetUtils.js | 4 ++-- dcc-network/qml/PageDetails.qml | 6 ++++-- dcc-network/qml/SectionIPv6.qml | 20 ++++++++++++-------- dcc-network/qml/dcc_network_edit.dci | Bin 0 -> 787 bytes 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 dcc-network/qml/dcc_network_edit.dci diff --git a/dcc-network/qml/NetUtils.js b/dcc-network/qml/NetUtils.js index e2eb6773..f72d4137 100644 --- a/dcc-network/qml/NetUtils.js +++ b/dcc-network/qml/NetUtils.js @@ -12,8 +12,8 @@ const VpnTypeEnum = Object.freeze({ "sstp": 0x40 }) // ip正则表达式 -const ipRegExp = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ -const ipv6RegExp = /^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|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]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))))$/ // 子网掩码 const maskRegExp = /(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)/ // MAC正则表达式 diff --git a/dcc-network/qml/PageDetails.qml b/dcc-network/qml/PageDetails.qml index c0f4b606..31476795 100644 --- a/dcc-network/qml/PageDetails.qml +++ b/dcc-network/qml/PageDetails.qml @@ -50,9 +50,11 @@ DccObject { D.IconLabel { property bool clipboard: false Layout.alignment: Qt.AlignRight - icon.name: "editcopy" - ToolTip { + icon.name: "dcc_network_edit" + icon.palette: D.DTK.makeIconPalette(parent.palette) + D.ToolTip { id: tip + palette: parent.palette } MouseArea { anchors.fill: parent diff --git a/dcc-network/qml/SectionIPv6.qml b/dcc-network/qml/SectionIPv6.qml index f367ac19..86b8b34b 100644 --- a/dcc-network/qml/SectionIPv6.qml +++ b/dcc-network/qml/SectionIPv6.qml @@ -274,7 +274,7 @@ DccObject { displayName: qsTr("IP Address") pageType: DccObject.Editor page: D.LineEdit { - text: addressData.length > index ? addressData[index].address : "" + text: root.addressData.length > index ? root.addressData[index].address : "" validator: RegularExpressionValidator { regularExpression: NetUtils.ipv6RegExp } @@ -282,8 +282,10 @@ DccObject { if (showAlert) { errorKey = "" } - if (addressData.length > index && addressData[index].address !== text) { - addressData[index].address = text + if (root.addressData.length > index && root.addressData[index].address !== text) { + var addr = root.addressData[index] + addr.address = text + root.addressData[index] = addr root.editClicked() } } @@ -305,15 +307,17 @@ DccObject { displayName: qsTr("Prefix") pageType: DccObject.Editor page: D.SpinBox { - value: addressData.length > index ? addressData[index].prefix : 64 + value: root.addressData.length > index ? root.addressData[index].prefix : 64 from: 0 to: 128 onValueChanged: { if (showAlert) { errorKey = "" } - if (addressData.length > index && addressData[index].prefix !== value) { - addressData[index].prefix = value + if (root.addressData.length > index && root.addressData[index].prefix !== value) { + var addr = root.addressData[index] + addr.prefix = value + root.addressData[index] = addr root.editClicked() } } @@ -376,10 +380,10 @@ DccObject { } onAddressDataChanged: { - while (addressData.length > ipItems.length) { + while (root.addressData.length > ipItems.length) { addIpItem() } - while (addressData.length < ipItems.length) { + while (root.addressData.length < ipItems.length) { removeIpItem() } } diff --git a/dcc-network/qml/dcc_network_edit.dci b/dcc-network/qml/dcc_network_edit.dci new file mode 100644 index 0000000000000000000000000000000000000000..b3ab64d47fc539cc6a441f382cae781a9b65c147 GIT binary patch literal 787 zcmZ>9_GDmWWME)2G-IFy9A<*(X3EPi%1zACOGzxsCda(BP)$t6bacE^o$aHV||#}Fi(TUNirUyxD6NqAV8_7?V#o`!W;%M zmSpl9R7a4fo7+1eJKWVNAS}Sb=OK`-uYZ7BV7{PW&uz0J8Jnu&9o2C*CTlycB)P1e z6u9)=!@s&8mpV6dC3sHCz4a>l_O{yWe~WkD`TJ*|(y#Lea&KF7+<14-{)?=C=ElsZ zsr&_*lBwSxtmS@IlwKX0J~QrV<=GGWx_M3{d%4xNXKcNeTWe6CXG zYhuPy!7aVzs%sVUr?w;?@#LMM8TEoE)}-O-AC?^%JP($bGOP~VKkvhZ5?eWwNx$Z~ HGcf=F^M03} literal 0 HcmV?d00001