feat(classic-games): 新增 Mini Krypto 小游戏#1235
Conversation
Made-with: Cursor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51417ebd6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const tokens = tokensFromExpression(expression).join(""); | ||
| if (tokens.replace(/\s/g, "") !== expression.replace(/\s/g, "")) { | ||
| throw new Error("Expression contains unsupported characters."); | ||
| } | ||
| return Function(`"use strict"; return (${expression});`)(); |
There was a problem hiding this comment.
Reject JavaScript comments before evaluating answers
When a player enters a JS block comment, the card check counts numbers inside the comment but Function ignores them, so invalid answers can be accepted. For example, on the [3, 5, 7, 8, 10] -> 24 deal, 3*8/*5*7*10*/ passes numbersUsed/sameCards and evaluates to 24 even though only 3 and 8 were actually used; reject comment delimiters or evaluate the parsed tokens instead of raw JavaScript.
Useful? React with 👍 / 👎.
Summary
project/classic-games/20260718-0524-krypto-lite.htmlValidation
startGame、tokensFromExpression、numbersUsed、sortedCards、sameCards、safeValue、checkAnswer、render、addEventListenernew Function(...)git diff --check -- project/classic-games/20260718-0524-krypto-lite.htmlAudit
run-audit.shOVERALL_EXIT=0/tmp/git-commit-audit-20260718-052701-76227Commit
e97c5780a3023fd50afcce5d2560b2b173bab7e051417ebd6cce3d3937016d0923dea31d8e4c930d