Add per-MIME clipboard size limits and OOM protection#3571
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3571 +/- ##
==========================================
+ Coverage 74.24% 74.41% +0.16%
==========================================
Files 252 253 +1
Lines 37498 37818 +320
Branches 5077 5105 +28
==========================================
+ Hits 27841 28141 +300
- Misses 9657 9677 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1911973 to
197657b
Compare
197657b to
db5fae8
Compare
There was a problem hiding this comment.
Pull request overview
Adds configurable per-MIME clipboard size limits (via config and env var) and hardens clipboard cloning against allocation failures so clipboard monitoring can continue under extreme clipboard contents.
Changes:
- Introduces
clipboard_mime_size_limitconfig option andCOPYQ_CLIPBOARD_MIME_SIZE_LIMITenv var parsing/caching for per-MIME byte limits. - Adds
std::bad_allochandling around severalQMimeDataaccessors used during clipboard cloning. - Adds tests and FAQ documentation for the new size-limit feature.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/common/clipboarddataguard.cpp | Implements rule parsing/caching, size enforcement, and OOM catches for clipboard reads. |
| src/common/appconfig.h | Adds Config::clipboard_mime_size_limit option definition. |
| src/gui/configurationmanager.cpp | Registers the new config option with the configuration system. |
| src/app/clipboardserver.cpp | Bumps a config generation counter to invalidate cached rules on reload. |
| src/tests/tests_other.cpp | Adds tests covering env-var and config-based size-limit behavior. |
| src/tests/tests.h | Declares new test slots. |
| docs/faq.rst | Documents how to configure clipboard size limits. |
| .gitignore | Ignores compile_commands.json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
db5fae8 to
53709e6
Compare
Add clipboard_mime_size_limit config option and COPYQ_CLIPBOARD_MIME_SIZE_LIMIT env var. Rules are semicolon-separated pattern:limit pairs (e.g. text/html.*:0;.*:100M). Default: .*:100M. Catch std::bad_alloc in ClipboardDataGuard leaf methods (data, text, urls, imageData, getUtf8Data). Guard parseByteSize against qint64 overflow. Enforce size limits in leaf methods so fallback paths in getImageData are also protected. Assisted-by: Claude (Anthropic)
0560b1c to
95ebee4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6f2bc64 to
55475cb
Compare
c9c8196 to
e3e371e
Compare
Split tests into per-group classes with a lightweight aggregator that dispatches to them. Adding a new test group is a single macro line. Individual tests are now discoverable via -datatags and selectable with group:tag syntax. Remove the old PLUGINS:<regex> argument. Update CI workflows and documentation to use the new syntax. CLI examples: ./copyq-tests testCore ./copyq-tests "testCore:configPath" ./copyq-tests -datatags COPYQ_TESTS_FILTER=clipboard ./copyq-tests Assisted-by: Claude (Anthropic)
6696e39 to
0dc5908
Compare
for more information, see https://pre-commit.ci
Add clipboard_mime_size_limit config option and
COPYQ_CLIPBOARD_MIME_SIZE_LIMIT env var. Rules are semicolon-separated
pattern:limit pairs (e.g. text/html.:0;.:100M). Default: .*:100M.
Catch std::bad_alloc in ClipboardDataGuard leaf methods (data, text,
urls, imageData, getUtf8Data). Guard parseByteSize against qint64
overflow. Enforce size limits in leaf methods so fallback paths in
getImageData are also protected.
Assisted-by: Claude (Anthropic)