mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Drop the last character for string length validation, bump version
This commit is contained in:
parent
7acb6aad32
commit
aa08f2ff33
11 changed files with 21 additions and 101 deletions
|
|
@ -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
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue