Skip to content

Commit 8b52e14

Browse files
Merge pull request #761 from ossf/redos_move_answers
Lab redos: Move answers to shared JavaScript
2 parents b789bdf + a221996 commit 8b52e14

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

docs/labs/redos.html

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@
1212

1313
<!-- See create_labs.md for how to create your own lab! -->
1414

15-
<!-- Sample expected answer -->
16-
<script id="expected0" type="plain/text">
17-
query('id').isLength({max:50}).matches( /^[A-Z0-9]+$/ ),
18-
</script>
19-
20-
<!-- Full pattern of correct answer -->
21-
<script id="correct0" type="plain/text">
22-
\s* query \( ('id'|"id"|`id`) \)
23-
\. isLength \( \{ max: 50 ,? \} \)
24-
\. matches \( \/\^\[A-Z0-9\]\+\$\/ \) , \s*
25-
</script>
26-
27-
2815
</head>
2916
<body>
3017
<!-- For GitHub Pages formatting: -->

docs/labs/redos.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,20 @@ info =
7171
present: String.raw`\[0-9[Aa]-[Zz]\]`,
7272
text: "It's conventional to list letters first, so use [A-Z0-9] not [0-9A-Z]"
7373
}
74-
]
74+
],
75+
expected: [
76+
"query('id').isLength({max:50}).matches( /^[A-Z0-9]+$/ ),",
77+
],
78+
correct: [
79+
String.raw`\s* query \(
80+
('id'|"id"|${BACKQUOTE}id${BACKQUOTE}) \)
81+
\. isLength \( \{ max: 50 ,? \} \)
82+
\. matches \( \/\^\[A-Z0-9\]\+\$\/ \) , \s*`,
83+
],
84+
successes: [
85+
[ " query ( `id` ) . isLength( {max:50} ).matches( /^[A-Z0-9]+$/ ) , " ],
86+
],
87+
failures: [
88+
[ "query('id').isLength({max:50}).matches( /^[A-Z]+$/ ),", ],
89+
],
7590
}

0 commit comments

Comments
 (0)