Drop the last character for string length validation, bump version

This commit is contained in:
Garth Vander Houwen 2024-04-04 09:39:03 -07:00
parent 7acb6aad32
commit aa08f2ff33
11 changed files with 21 additions and 101 deletions

View file

@ -1611,7 +1611,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.3.3;
MARKETING_VERSION = 2.3.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -1645,7 +1645,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.3.3;
MARKETING_VERSION = 2.3.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -1767,7 +1767,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.3.3;
MARKETING_VERSION = 2.3.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -1800,7 +1800,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.3.3;
MARKETING_VERSION = 2.3.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View file

@ -53,11 +53,7 @@ struct WaypointFormMapKit: View {
let totalBytes = name.utf8.count
// Only mess with the value if it is too big
if totalBytes > 30 {
let firstNBytes = Data(name.utf8.prefix(30))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the name back to the last place where it was the right size
name = maxBytesString
}
name = String(name.dropLast())
}
})
}
@ -74,11 +70,7 @@ struct WaypointFormMapKit: View {
let totalBytes = description.utf8.count
// Only mess with the value if it is too big
if totalBytes > 100 {
let firstNBytes = Data(description.utf8.prefix(100))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the name back to the last place where it was the right size
description = maxBytesString
}
description = String(description.dropLast())
}
})
}

View file

@ -33,13 +33,7 @@ struct TextMessageField: View {
totalBytes = value.utf8.count
// Only mess with the value if it is too big
if totalBytes > Self.maxbytes {
let firstNBytes = Data(typingMessage.utf8.prefix(Self.maxbytes))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the message back to the last place where it was the right size
typingMessage = maxBytesString
} else {
print("not a valid UTF-8 sequence")
}
typingMessage = String(typingMessage.dropLast())
}
})
.keyboardType(.default)

View file

@ -63,11 +63,7 @@ struct WaypointForm: View {
let totalBytes = name.utf8.count
// Only mess with the value if it is too big
if totalBytes > 30 {
let firstNBytes = Data(name.utf8.prefix(30))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the name back to the last place where it was the right size
name = maxBytesString
}
name = String(name.dropLast())
}
})
}
@ -84,11 +80,7 @@ struct WaypointForm: View {
let totalBytes = description.utf8.count
// Only mess with the value if it is too big
if totalBytes > 100 {
let firstNBytes = Data(description.utf8.prefix(100))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the name back to the last place where it was the right size
description = maxBytesString
}
description = String(description.dropLast())
}
})
}

View file

@ -47,11 +47,7 @@ struct ChannelForm: View {
let totalBytes = channelName.utf8.count
// Only mess with the value if it is too big
if totalBytes > 11 {
let firstNBytes = Data(channelName.utf8.prefix(11))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the channelName back to the last place where it was the right size
channelName = maxBytesString
}
channelName = String(channelName.dropLast())
}
hasChanges = true
})

View file

@ -74,12 +74,7 @@ struct CannedMessagesConfig: View {
let totalBytes = messages.utf8.count
// Only mess with the value if it is too big
if totalBytes > 198 {
let firstNBytes = Data(messages.utf8.prefix(198))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
messages = maxBytesString
}
messages = String(messages.dropLast())
}
hasMessagesChanges = true
})

View file

@ -94,12 +94,7 @@ struct DetectionSensorConfig: View {
let totalBytes = name.utf8.count
// Only mess with the value if it is too big
if totalBytes > 20 {
let firstNBytes = Data(name.utf8.prefix(20))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
name = maxBytesString
}
name = String(name.dropLast())
}
})
}

View file

@ -139,11 +139,7 @@ struct MQTTConfig: View {
let totalBytes = root.utf8.count
// Only mess with the value if it is too big
if totalBytes > 30 {
let firstNBytes = Data(root.utf8.prefix(30))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
root = maxBytesString
}
root = String(root.dropLast())
}
})
.foregroundColor(.gray)
@ -181,11 +177,7 @@ struct MQTTConfig: View {
let totalBytes = address.utf8.count
// Only mess with the value if it is too big
if totalBytes > 62 {
let firstNBytes = Data(username.utf8.prefix(62))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
address = maxBytesString
}
address = String(address.dropLast())
}
hasChanges = true
})
@ -205,14 +197,7 @@ struct MQTTConfig: View {
// Only mess with the value if it is too big
if totalBytes > 62 {
let firstNBytes = Data(username.utf8.prefix(62))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
username = maxBytesString
}
username = String(username.dropLast())
}
hasChanges = true
})
@ -229,17 +214,9 @@ struct MQTTConfig: View {
.onChange(of: password, perform: { _ in
let totalBytes = password.utf8.count
// Only mess with the value if it is too big
if totalBytes > 62 {
let firstNBytes = Data(password.utf8.prefix(62))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
password = maxBytesString
}
password = String(password.dropLast())
}
hasChanges = true
})

View file

@ -35,12 +35,7 @@ struct RtttlConfig: View {
let totalBytes = ringtone.utf8.count
// Only mess with the value if it is too big
if totalBytes > 228 {
let firstNBytes = Data(ringtone.utf8.prefix(228))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the ringtone back to the last place where it was the right size
ringtone = maxBytesString
}
ringtone = String(ringtone.dropLast())
}
})
.foregroundColor(.gray)

View file

@ -48,11 +48,7 @@ struct NetworkConfig: View {
let totalBytes = wifiSsid.utf8.count
// Only mess with the value if it is too big
if totalBytes > 32 {
let firstNBytes = Data(wifiSsid.utf8.prefix(32))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
wifiSsid = maxBytesString
}
wifiSsid = String(wifiSsid.dropLast())
}
hasChanges = true
})
@ -69,11 +65,7 @@ struct NetworkConfig: View {
let totalBytes = wifiPsk.utf8.count
// Only mess with the value if it is too big
if totalBytes > 63 {
let firstNBytes = Data(wifiPsk.utf8.prefix(63))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
wifiPsk = maxBytesString
}
wifiPsk = String(wifiPsk.dropLast())
}
hasChanges = true
})

View file

@ -52,11 +52,7 @@ struct UserConfig: View {
let totalBytes = longName.utf8.count
// Only mess with the value if it is too big
if totalBytes > (isLicensed ? 6 : 36) {
let firstNBytes = Data(longName.utf8.prefix(isLicensed ? 6 : 36))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the longName back to the last place where it was the right size
longName = maxBytesString
}
longName = String(longName.dropLast())
}
})
}
@ -80,11 +76,7 @@ struct UserConfig: View {
let totalBytes = shortName.utf8.count
// Only mess with the value if it is too big
if totalBytes > 4 {
let firstNBytes = Data(shortName.utf8.prefix(4))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
shortName = maxBytesString
}
shortName = String(shortName.dropLast())
}
})
.foregroundColor(.gray)