Skip to content

Instantly share code, notes, and snippets.

@Meettya
Created July 1, 2024 10:07
Show Gist options
  • Save Meettya/639ed464d038d584a72fb62e71045013 to your computer and use it in GitHub Desktop.
Save Meettya/639ed464d038d584a72fb62e71045013 to your computer and use it in GitHub Desktop.
valid cookie value
// %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
const res = []
res.push(String.fromCharCode(0x21))
for (let i = 0x23; i <= 0x2b; i++) {
res.push(String.fromCharCode(i));
}
for (let i = 0x2d; i <= 0x3a; i++) {
res.push(String.fromCharCode(i));
}
for (let i = 0x3c; i <= 0x5b; i++) {
res.push(String.fromCharCode(i));
}
for (let i = 0x5d; i <= 0x7e; i++) {
res.push(String.fromCharCode(i));
}
const resStr = res.join();
const checkRe = /^"?[!#$%&'()*+-./\d:<=>?@a-z[\]^_`{|}~]+"?$/i;
const matched = resStr.match(checkRe);
console.log(matched)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment