Repository navigation
Adds more robust copy/paste checking - #15
Merged
Merged
Conversation
…roved matching - Wrapping selected text in a quote/bracket pair (one edit, old -> opener+old+closer) is an IDE action, not a paste. - A paste of internal/approved text stays internal/approved when another edit in the same 250 ms burst changes it; the text as first pasted is checked as well as the final text. - --approved-pastes takes one or more files, each its own source. - Approved pastes get a second, looser match: comment/Markdown line markers, bold and code marks and typographic quotes are ignored and whitespace is collapsed, so text copied from the rendered instructions matches the Markdown source. Needs at least 12 characters after simplifying. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
byubean
reviewed
Nov 5, 2026
|
|
||
| ## Unreleased | ||
|
|
||
| - Approved pastes are matched loosely as a second chance: line markers (`#`, Markdown headings, list numbers and bullets), bold and code marks and typographic quotes are ignored, and line wraps and runs of whitespace don't matter. A paste of instructions copied from the rendered page now matches the Markdown source. Code is not made whitespace-insensitive (`x=1` still differs from `x = 1`). The loose match needs at least 12 characters after simplifying, so a marker can't shrink a short paste (`- a`) into a match. |
Contributor
There was a problem hiding this comment.
Why 12 characters? Why not fewer?
Contributor
Author
There was a problem hiding this comment.
The original idea was that if a student pasted something really short like - the the loose checking would strip out the hyphen and leading space to result in just the which is extremely likely to match something from the instructions just in the nature of being such a short/common substring. The 12 was an arbitrary limit.
On reflection, I can't think of a scenario where this behavior could be used maliciously by a student, so I just dropped the minimum check altogether. If they want to paste - the for whatever reason, I don't see a reason to flag it.
Contributor
|
Need to bump the version (VERSION and Changelog). |
byubean
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Surround edits are IDE actions:
_is_surround_edittreats an edit as an IDE action when its new text is exactly the old text wrapped in ', ", `, ''', """, (), [] or {}.Edited pastes keep their classification:
_classify_clusternow checks the text as first pasted as well as the final text, for both the approved and internal checks. Before, a change inside the burst could leave a final text that never existed. For example, if you had the text("Jack","Johnson")and copied and pasted it internally, PyCharm automatically inserts a space after the comma so that it becomes("Jack", "Johnson")which gets flagged as unapproved instead of internal.--approved-pastes FILE [FILE ...] takes one or more files: Previously the flag only accepted one file. This change was made so that recan can be run with expected test output and instructions as arguments so that students copying and pasting from them (ex. copying
Enter a Number:from the expected output) are flagged as approved pastes instead of unapproved.Loose approved matching: runs as a second chance after the exact text check fails. It drops # and Markdown line markers, **, backticks and typographic quotes, and collapses whitespace. This change was made to normalize content students copy from canvas or test output.
Tests
38 new tests; the total goes from 148 to 186. They cover: