Fix WiFi (ZX or DPP) QR code parsing to ignore leading spaces

Increase robustness of QR code parsing: while leading spaces aren't
expected (or allowed) they are observed in the wild and can be safely
ignored.

Bug: 292331368
Test: validated that QR code with scan is now parsed correctly
Test: atest WifiQrCodeTest
Change-Id: Ifff79870bea2ec9924f7b2e8100c2c01fd350846
This commit is contained in:
Etan Cohen
2023-08-03 03:06:14 +00:00
parent 3e25353a21
commit 0fb1a3b3a7
2 changed files with 77 additions and 2 deletions

View File

@@ -160,8 +160,9 @@ public class WifiQrCode {
private String getValueOrNull(List<String> keyValueList, String prefix) {
for (String keyValue : keyValueList) {
if (keyValue.startsWith(prefix)) {
return keyValue.substring(prefix.length());
String strippedKeyValue = keyValue.stripLeading();
if (strippedKeyValue.startsWith(prefix)) {
return strippedKeyValue.substring(prefix.length());
}
}