- From: François Beaufort via GitHub <sysbot+gh@w3.org>
- Date: Mon, 27 Jun 2022 09:43:48 +0000
- To: public-web-nfc@w3.org
FYI Here's the [current implementation](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/nfc/ndef_record.cc;l=91;drc=f0ec23f77f2076e7ef2042c129d162e59ba755f8) of this algorithm in Chromium:
```cpp
// https://w3c.github.io/web-nfc/#dfn-validate-external-type
// Validates |input| as an external type.
bool IsValidExternalType(const String& input) {
static const String kOtherCharsForCustomType(":!()+,-=@;$_*'.");
// Ensure |input| is an ASCII string.
if (!input.ContainsOnlyASCIIOrEmpty())
return false;
// As all characters in |input| is ASCII, limiting its length within 255 just
// limits the length of its utf-8 encoded bytes we finally write into the
// record payload.
if (input.IsEmpty() || input.length() > 255)
return false;
// Finds the first occurrence of ':'.
wtf_size_t colon_index = input.find(':');
if (colon_index == kNotFound)
return false;
// Validates the domain (the part before ':').
String domain = input.Left(colon_index);
if (domain.IsEmpty())
return false;
// TODO(https://crbug.com/520391): Validate |domain|.
// Validates the type (the part after ':').
String type = input.Substring(colon_index + 1);
if (type.IsEmpty())
return false;
for (wtf_size_t i = 0; i < type.length(); i++) {
if (!IsASCIIAlphanumeric(type[i]) &&
!kOtherCharsForCustomType.Contains(type[i])) {
return false;
}
}
return true;
}
```
@kenchris Which changes are you suggesting?
--
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/642#issuecomment-1167126588 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 27 June 2022 09:43:50 UTC