fix(chrome): use strconv.Atoi for extractor key parsing

fmt.Sscanf("%d", ...) silently accepts trailing garbage like "3abc"
as 3. strconv.Atoi rejects the same input outright, so a malformed
key surfaces as an error instead of a wrong-bucket override.
This commit is contained in:
pj committed 2026-05-03 11:08:10 +07:00
1 parent 8a0a8e2dfb
commit 07ae3f265d
1 file changed
+3 -2
+3 -2
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strconv"
"strings"
"sync"
"time"
@@ -390,8 +391,8 @@ func (d *Driver) EvaluateExtractors(ctx context.Context) (map[int]json.RawMessag
}
result := make(map[int]json.RawMessage, len(stringMap))
for key, value := range stringMap {
index := 0
if _, err := fmt.Sscanf(key, "%d", &index); err != nil {
index, err := strconv.Atoi(key)
if err != nil {
return nil, fmt.Errorf("non-integer extractor key %q", key)
}
result[index] = value