Skip to content

[stable35] fix: restore initial crop selection for uploaded signatures - #9751

Merged
vitormattos merged 6 commits into
stable35from
backport/9528/stable35
Nov 29, 2026
Merged

vitormattos merged 6 commits into
stable35from
backport/9528/stable35

Conversation

@backportbot-libresign

@backportbot-libresign backportbot-libresign Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Backport of #9528

Warning, This backport's changes differ from the original and might be incomplete ⚠️

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
style: format cropper canvas constraints for ESLint

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>

[skip ci]
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Intended behavior: Restore the cropper's default crop selection for uploaded signatures. The cropper, not the component, sets the initial selection size. Bound the exported PNG size.

Actual behavior (verified in the diff):

  • FileUpload.vue removes the container-width measurement, the ResizeObserver handling, and defaultStencilSize. The Cropper no longer receives :default-size.
  • Cropper receives a new :canvas prop from canvasConstraints. It sets maxWidth to 3× the stencil base width (2100), maxHeight to 3× the base height (600), and maxArea to 1,000,000. Each width or height bound is undefined unless its value is finite and positive.
  • Clearing the image resets zoom, pending centering, and imageData.
  • Removed items are no longer exposed through defineExpose.

Contract change: Component-internal state and helpers (containerWidth, resizeObserver, defaultStencilSize, updateContainerWidth, initResizeObserver) are removed. No exported declarations change.

Tests: The spec mock accepts canvas. New assertions check the 3.5 aspect ratio, that no defaultSize is passed, and the canvas constraint values. The clear-image test checks imageData. No test or CI run results are available for this head.

Non-blocking follow-ups:

  • The mock still lists defaultSize in its props. It is stale but harmless.
  • The test titled "retaining source resolution for small images" asserts only the constraint object. It does not check that small images keep their size.
  • The code comment says a 1 MP RGBA canvas stays under the backend's 5000 KiB limit. This was not verified against the backend.

No confirmed defects found.

Changes: File upload crop sizing

Layer / File(s) Summary
Cropper sizing and state
src/components/Draw/FileUpload.vue, src/tests/components/Draw/FileUpload.spec.ts
The cropper receives a maximum output area of 1,000,000 pixels and conditional width and height limits. Initial crop sizing is delegated to the cropper. Container resize handling is removed. Clearing the image resets generated image data; tests cover the updated sizing and reset behavior.

Possibly related issues

  • LibreSign/libresign#9526: The issue describes incorrect initial crop-frame sizing in FileUpload.vue, which this change addresses by delegating the initial size to the cropper.

Possibly related PRs

Change: Bug fix

Merge Risk: Minimal · up to 09c28

This change restores the initial crop selection for uploaded signatures by letting the cropper choose the starting size, and it caps exported image dimensions. No concrete defect was found, and the size cap stays within the backend's limit.

Security architecture risk: Minimal · up to 09c28

The change affects how a signature image is cropped and resized before upload. It does not weaken the server’s existing file size and type checks or expand who can save a signature.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed processing is confined to the browser’s signature-image export and the image bytes delivered through the existing save path. The comparison shows no expansion of that path’s authority or server-side reach.

Trust Boundaries and Controls

  • observed — The cropper settings are a client-side export control. The server continues to enforce PNG type and a 5000 KiB decoded-byte limit for user-visible signature elements independently of the client settings.
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ab833790-00f6-4093-ad92-10f74fe6b042
Commits

Reviewing files that changed from the base of the PR and between bb9e84a and 09c282b.

Files selected for processing: 2

  • src/components/Draw/FileUpload.vue
  • src/tests/components/Draw/FileUpload.spec.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: node
  • GitHub Check: NPM lint
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: CodeRabbit
  • GitHub Check: php-lint (8.5)
  • GitHub Check: php-lint (8.3)
  • GitHub Check: static-psalm-analysis
Additional context used

Code guidelines: 4

AGENTS.md — configured
3 cross-repository guideline sources
Path-based instructions: 4

Source excerpt: Frontend unit tests should mirror the source tree under `src/tests/`.

CodeRabbit inference engine (AGENTS.md)

Files:

  • src/tests/components/Draw/FileUpload.spec.ts
Source excerpt: Prefer named independent cases for inputs that share the **same** setup, action, contract and expectation.

CodeRabbit inference engine

Files:

  • src/components/Draw/FileUpload.vue
  • src/tests/components/Draw/FileUpload.spec.ts
Source excerpt: Tests are also code to review.

CodeRabbit inference engine

Files:

  • src/components/Draw/FileUpload.vue
  • src/tests/components/Draw/FileUpload.spec.ts
Source excerpt: For integration tests changing persistent state, snapshot only the relevant pre-test values and restore them in a reliable teardown/finally path; preserve absent-vs-empty and types.

CodeRabbit inference engine

Files:

  • src/components/Draw/FileUpload.vue
  • src/tests/components/Draw/FileUpload.spec.ts
Learnings: 2

Learning: 2026-11-26T12:28:40.957Z

Learnt from: CR
Repo: LibreSign/libresign PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-26T12:28:40.957Z
Learning: Source excerpt:
# LibreSign operational guide

## Areas requiring extra care

### Certificates and PDF

- Prefer minimal synthetic fixtures when they prove the rule.

Applied to files:

  • src/tests/components/Draw/FileUpload.spec.ts
Learning: 2026-11-26T12:28:40.957Z

Learnt from: CR
Repo: LibreSign/libresign PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-26T12:28:40.957Z
Learning: Applies to src/tests/** : Source excerpt:
# LibreSign operational guide

## Command discovery and testing map

### Frontend

Frontend unit tests should mirror the source tree under `src/tests/`.

Applied to files:

  • src/tests/components/Draw/FileUpload.spec.ts
Additional comments: 1

src/components/Draw/FileUpload.vue: 1

215-215: Data Integrity & Integration

The review concern does not hold. The backend's 5000 KiB limit applies to decoded PNG bytes, not to the base64 or data-URL string. The canvas pixel bound keeps a one-megapixel RGBA PNG well below that limit, so the source comment at src/components/Draw/FileUpload.vue:215 is accurate.

Complete the template change from #9528 while preserving the stable branch layout.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
vitormattos marked this pull request as ready for review November 29, 2026 19:41
@vitormattos
vitormattos requested a review from a team as a code owner November 29, 2026 19:41
@vitormattos
vitormattos merged commit 74a4dea into stable35 Nov 29, 2026
60 of 61 checks passed
@vitormattos
vitormattos deleted the backport/9528/stable35 branch November 29, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant