Skip to content

Commit fefc024

Browse files
btsheehyBrandon Sheehy (Contractor)
and
Brandon Sheehy (Contractor)
authored
fix: forbidden KV key special characters to match documentation (#1097)
Co-authored-by: Brandon Sheehy (Contractor) <[email protected]>
1 parent bc03ff0 commit fefc024

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

documentation/docs/kv-store/KVStore/prototype/delete.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Returns `undefined`
2929
- If the provided `key`:
3030
- Is any of the strings `""`, `"."`, or `".."`
3131
- Starts with the string `".well-known/acme-challenge/"`
32-
- Contains any of the characters `"#?*[]\n\r"`
32+
- Contains any of the characters `"#;?^|\n\r"`
3333
- Is longer than 1024 characters
3434
- Does not exist
3535

documentation/docs/kv-store/KVStore/prototype/get.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If the `this` value does not inherit from `KVStore.prototype`, a [`TypeError`](.
4141
- If the provided `key`:
4242
- Is any of the strings `""`, `"."`, or `".."`
4343
- Starts with the string `".well-known/acme-challenge/"`
44-
- Contains any of the characters `"#?*[]\n\r"`
44+
- Contains any of the characters `"#;?^|\n\r"`
4545
- Is longer than 1024 characters
4646

4747
## Examples

documentation/docs/kv-store/KVStore/prototype/put.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ If the `this` value does not inherit from `KVStore.prototype`, a [`TypeError`](.
4949
- If the provided `key`:
5050
- Is any of the strings `""`, `"."`, or `".."`
5151
- Starts with the string `".well-known/acme-challenge/"`
52-
- Contains any of the characters `"#?*[]\n\r"`
52+
- Contains any of the characters `"#;?^|\n\r"`
5353
- Is longer than 1024 characters
5454
5555
## Examples

integration-tests/js-compute/fixtures/module-mode/src/kv-store.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ const debug = sdkVersion.endsWith('-debug');
492492
routes.set(
493493
'/kv-store/put/key-parameter-containing-special-characters',
494494
async () => {
495-
const specialCharacters = ['[', ']', '*', '?', '#'];
495+
const specialCharacters = [';', '^', '|', '#', '?'];
496496
for (const character of specialCharacters) {
497497
await assertRejects(
498498
async () => {
@@ -993,7 +993,7 @@ const debug = sdkVersion.endsWith('-debug');
993993
routes.set(
994994
'/kv-store/delete/key-parameter-containing-special-characters',
995995
async () => {
996-
const specialCharacters = ['[', ']', '*', '?', '#'];
996+
const specialCharacters = [';', '^', '|', '#', '?'];
997997
for (const character of specialCharacters) {
998998
await assertRejects(
999999
async () => {
@@ -1224,7 +1224,7 @@ const debug = sdkVersion.endsWith('-debug');
12241224
routes.set(
12251225
'/kv-store/get/key-parameter-containing-special-characters',
12261226
async () => {
1227-
const specialCharacters = ['[', ']', '*', '?', '#'];
1227+
const specialCharacters = [';', '^', '|', '#', '?'];
12281228
for (const character of specialCharacters) {
12291229
await assertRejects(
12301230
async () => {

runtime/fastly/builtins/kv-store.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace {
3939

4040
api::Engine *ENGINE;
4141

42-
std::string_view bad_chars{"#?*[]\n\r"};
42+
std::string_view bad_chars{"#;?^|\n\r"};
4343

4444
std::optional<char> find_invalid_character_for_kv_store_key(const char *str) {
4545
std::optional<char> res;
@@ -205,14 +205,14 @@ bool parse_and_validate_key(JSContext *cx, const char *key, size_t len) {
205205
case '\r':
206206
character = "carriage return";
207207
break;
208-
case '[':
209-
character = '[';
208+
case '^':
209+
character = '^';
210210
break;
211-
case ']':
212-
character = ']';
211+
case '|':
212+
character = '|';
213213
break;
214-
case '*':
215-
character = '*';
214+
case ';':
215+
character = ';';
216216
break;
217217
case '?':
218218
character = '?';

types/globals.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ declare class KVStore {
636636
* @param key The key to retrieve from within the KV Store. A key cannot:
637637
* - Be any of the strings "", ".", or ".."
638638
* - Start with the string ".well-known/acme-challenge/""
639-
* - Contain any of the characters "#?*[]\n\r"
639+
* - Contain any of the characters "#;?^|\n\r"
640640
* - Be longer than 1024 characters
641641
*/
642642
get(key: string): Promise<KVStoreEntry | null>;
@@ -650,7 +650,7 @@ declare class KVStore {
650650
* @param key The key to associate with the value. A key cannot:
651651
* - Be any of the strings "", ".", or ".."
652652
* - Start with the string ".well-known/acme-challenge/""
653-
* - Contain any of the characters "#?*[]\n\r"
653+
* - Contain any of the characters "#;?^|\n\r"
654654
* - Be longer than 1024 characters
655655
* @param value The value to store within the KV Store.
656656
*/

types/kv-store.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare module 'fastly:kv-store' {
4343
* @param key The key to retrieve from within the KV Store. A key cannot:
4444
* - Be any of the strings "", ".", or ".."
4545
* - Start with the string ".well-known/acme-challenge/""
46-
* - Contain any of the characters "#?*[]\n\r"
46+
* - Contain any of the characters "#;?^|\n\r"
4747
* - Be longer than 1024 characters
4848
*/
4949
delete(key: string): Promise<undefined>;
@@ -55,7 +55,7 @@ declare module 'fastly:kv-store' {
5555
* @param key The key to retrieve from within the KV Store. A key cannot:
5656
* - Be any of the strings "", ".", or ".."
5757
* - Start with the string ".well-known/acme-challenge/""
58-
* - Contain any of the characters "#?*[]\n\r"
58+
* - Contain any of the characters "#;?^|\n\r"
5959
* - Be longer than 1024 characters
6060
*/
6161
get(key: string): Promise<KVStoreEntry | null>;
@@ -69,7 +69,7 @@ declare module 'fastly:kv-store' {
6969
* @param key The key to associate with the value. A key cannot:
7070
* - Be any of the strings "", ".", or ".."
7171
* - Start with the string ".well-known/acme-challenge/""
72-
* - Contain any of the characters "#?*[]\n\r"
72+
* - Contain any of the characters "#;?^|\n\r"
7373
* - Be longer than 1024 characters
7474
* @param value The value to store within the KV Store.
7575
*/

0 commit comments

Comments
 (0)