Commit 5bfd7ff6 authored by Adam Langley's avatar Adam Langley Committed by Commit Bot

device/fido: add some comments about the string fixup.

Walked by this function for unrelated reasons but it struck me that I
really should have added some comments when writing it.

Change-Id: Idab9e6ac0054b640b37aad1d3ec6ba88e5ffb6a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250892
Commit-Queue: Adam Langley <agl@chromium.org>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Auto-Submit: Adam Langley <agl@chromium.org>
Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#779612}
parent ac0fc86b
...@@ -61,11 +61,15 @@ void GetAssertionTask::Cancel() { ...@@ -61,11 +61,15 @@ void GetAssertionTask::Cancel() {
// static // static
bool GetAssertionTask::StringFixupPredicate( bool GetAssertionTask::StringFixupPredicate(
const std::vector<const cbor::Value*>& path) { const std::vector<const cbor::Value*>& path) {
// This filters out all elements that are not string-keyed, direct children
// of key 0x04, which is the `user` element of a getAssertion response.
if (path.size() != 2 || !path[0]->is_unsigned() || if (path.size() != 2 || !path[0]->is_unsigned() ||
path[0]->GetUnsigned() != 4 || !path[1]->is_string()) { path[0]->GetUnsigned() != 4 || !path[1]->is_string()) {
return false; return false;
} }
// Of those string-keyed children, only `name` and `displayName` may have
// truncated UTF-8 in their values.
const std::string& user_key = path[1]->GetString(); const std::string& user_key = path[1]->GetString();
return user_key == "name" || user_key == "displayName"; return user_key == "name" || user_key == "displayName";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment