mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-05 04:27:09 +00:00
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:
1 parent
8a0a8e2dfb
commit
07ae3f265d
1 file changed
+3
-2
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -390,8 +391,8 @@ func (d *Driver) EvaluateExtractors(ctx context.Context) (map[int]json.RawMessag
|
|||||||
}
|
}
|
||||||
result := make(map[int]json.RawMessage, len(stringMap))
|
result := make(map[int]json.RawMessage, len(stringMap))
|
||||||
for key, value := range stringMap {
|
for key, value := range stringMap {
|
||||||
index := 0
|
index, err := strconv.Atoi(key)
|
||||||
if _, err := fmt.Sscanf(key, "%d", &index); err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("non-integer extractor key %q", key)
|
return nil, fmt.Errorf("non-integer extractor key %q", key)
|
||||||
}
|
}
|
||||||
result[index] = value
|
result[index] = value
|
||||||
|
|||||||
Reference in new issue
Block a user