-- -*- Mode: rpl; -*- -- -- cloudflare.rpl -- -- AUTHOR: Jamie A. Jennings -- NOTE: Requires Rosie 1.1 to ensure the tests of local definitions to work, -- and Rosie 1.2 if you want to remove the package declaraction below, and still -- want tests of local definitions to work. package cf -- Optional! -- A reformatted version of the regex cited at -- https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/ -- -- 1 (?: -- 2 (?: -- 3 \"|'|\]|\}|\\|\d| -- 4 (?: -- 5 nan|infinity|true|false|null|undefined|symbol|math -- 6 )| -- 7 \`|\-|\+ -- 8 )+ -- 9 [)]*;? -- 10 ( -- 11 (?: -- 12 \s|-|~|!|{}|\|\||\+ -- 13 )* -- 14 .* -- 15 (?: -- 16 .*=.* -- 17 ) -- 18 ) -- 19 ) -- Lines 2-8 alias opening = { ["'\]}\\] / [:digit:] / keywords / [`\-+] }+ -- Line 4-6 alias keywords = "nan" / "infinity" / "true" / "false" / "null" / "undefined" / "symbol" / "math" -- Line 9 alias closing = { ")"* ";"? } -- Lines 11-13 alias misc = [ [:space:] [\-~!] "{}" "||" "+" ]* -- Lines 15-17 identifier = find:"=" alias rest_of_input = .* -- Lines 1-19 alias pattern = { opening closing misc identifier rest_of_input } -- test opening accepts "+1'''1234`-`-`-`+" -- test opening rejects "", " ", "☃" -- test closing accepts "", ";", ")", ");", "))))));" -- test misc accepts "", "- -\t\n~{}{}+ ||" -- test misc rejects "|", "- {", "}" -- test identifier accepts "a=", "=", "a b c d =", "◆=" -- test identifier rejects "", " ", "a", "a b" local alias identifier_and_rest = { identifier rest_of_input } -- test local identifier_and_rest accepts "a = 4.0", "foo=bar", "s ='a string' ", "=" -- test local identifier_and_rest accepts "a========" -- test local identifier_and_rest rejects "", "a is 4.0" -- test pattern accepts "+++'1299--]]false`\"nan))))); +|| s = 'a string'" -- test pattern accepts "\\t=\"another string\"" -- test pattern accepts "1t=\"another string\"" -- test pattern includes identifier "1t=\"another string\"", "] a = 4.0" -- test pattern rejects "t=\"another string\""