Skip to content

T3630 participant original photo - #446

Closed
danpa32 wants to merge 4 commits into
18.0from
T3630-participant-original-photo
Closed

danpa32 wants to merge 4 commits into
18.0from
T3630-participant-original-photo

Conversation

@danpa32

@danpa32 danpa32 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

[T3630] Keep the participant's original photo and link it in the new registration messages

Branch T3630-participant-original-photo in compassion-website, based on origin/18.0:

  • 1be124d7 original photo, download links, clear upload error, tests
  • dcd0947e download named after the participant
  • 31f1e4e4 review: keep the uploaded picture itself instead of a second copy
  • af0ba830 merge of the latest 18.0

Problem

When someone registers for a Muskathlon or a trip, the profile picture they upload is only stored resized (500 px before, 1920 px since T3266). The file as uploaded is not kept anywhere, so the events team has to ask participants again for an HD version for print material. The "New Muskathlon registration" e-mail lists the registration details but has no way to get the picture.

While testing, two more issues showed up:

  • Odoo also resizes every stored JPG/PNG attachment to 1920 px (base.image_autoresize_max_px).
  • A picture Odoo cannot read (typically an iPhone HEIC photo) or one above 50 megapixels makes the registration form fail with the generic "An error occurred, the form was not sent": Odoo's image error is a lazy translation that the website form cannot send back to the browser.

Change

website_event_compassion:

  • profile_picture is stored as uploaded: no size cap on the field anymore, and it is written without the attachment auto-resize (image_no_postprocess). Web pages are unaffected: they already request resized versions (/web/image/.../1024x1024, /event/registration/<id>/photo/<size>), the shop line image and the partner image keep their own caps.
  • The "New registration" note posted on the event for its responsible gets a "Download the profile picture" link (trips and all other events). The file downloads as <participant name>.jpg (or .png, from the stored file's type), named when the message is sent.
  • The link goes through /web/login?redirect=...: logged-in staff download directly, logged-out staff log in first (the download alone answers Not Found when logged out).
  • Uploaded pictures are checked before Odoo processes them: unreadable files, pictures above 50 Mpx and pictures Pillow refuses to open at all (decompression bomb, about 180 Mpx) are refused with a message asking for a JPG or PNG file.
  • The upload fields of the registration form and of "My events" only offer JPG and PNG (accept), so iPhones convert HEIC photos to JPEG by themselves.
  • Duplicating a registration keeps its picture and skips the upload checks.

muskathlon:

  • The "New Muskathlon registration" e-mail gets a "Profile picture: Download" line; the link is passed to the template as a render value.

fr/de/it translations for all new texts.

Pictures uploaded before this change cannot be recovered: only the resized version was ever stored.

Review of the first version

The first version kept a second field, profile_picture_original, beside the capped picture. Following the review, it is gone: one picture, stored as uploaded. This also removes the duplicate copy in the filestore, the stored file name, and the case where a duplicated registration got the capped picture as its "original". No migration is needed: the field never reached 18.0 or stage.

Not changed from the review:

  • The "My events" edit form does run the checks: the form's related image field passes the uploaded picture to the registration's write() untouched. A test now covers it.
  • accept in the form builder (registration_form_snippet.esm.js): Odoo 18's website form editor has no accept option for file fields, so it would need an override of the core template.

Deploy

-u website_event_compassion,muskathlon

…registration messages

- website_event_compassion: new staff-only field profile_picture_original
  holds the uploaded picture as received (attachment auto-resize skipped),
  refreshed on each new upload; download button on the registration form.
- The "New registration" note to the event responsible and the Muskathlon
  registration e-mail link the original through the login page.
- Unreadable (e.g. HEIC) or oversized pictures are refused with a message
  naming JPG/PNG instead of the website form's generic error; the upload
  fields only offer JPG and PNG.
- fr/de/it translations, tests in both modules.
The original picture is downloaded as "<participant name>.<jpg|png>"
instead of event.registration-<id>-profile_picture_original, from the
e-mail links and from the registration form.
Review of #440: profile_picture is no longer resized (field cap and
attachment auto-resize), so the staff download it as uploaded and the
profile_picture_original fields are dropped. The download link is named
after the participant when the message is sent, and is passed to the
Muskathlon mail as a render value. Pictures Pillow refuses to open
(decompression bomb) get the 'too large' message, and a duplicate skips
the upload checks.
@danpa32
danpa32 requested a review from ecino November 4, 2026 10:36
@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The changes affect participant photo uploads and staff registration notifications.

Restrict the public photo response before merging so anonymous visitors cannot retrieve the original upload.

Findings

  1. P1 Security Original photos become public ▶

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Participant uploads photo] --> B[Original stored in profile_picture]
    B --> C[Staff notification]
    C --> D[Login and named download]
    B --> E[Public photo route]
    E --> F{Dimensions requested?}
    F -->|Yes| G[Smaller image]
    F -->|No| H[Original photo exposed]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/18...." · Reviewed by Greptile

Comment on lines +130 to +133
# Stored as uploaded, not resized: the staff download it in full quality
# to print it on fundraising material (T3630). Web pages request a smaller
# version through /web/image/ or /event/registration/<id>/photo/.
profile_picture = fields.Image(readonly=False, string="Profile picture")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Original photos become public

Keeping the original in profile_picture also exposes it through /event/registration/<id>/photo. That public route reads published registrations with sudo() and accepts requests without dimensions. Anyone can now retrieve the full uploaded photo instead of the previously capped copy, including any retained location or other EXIF metadata.

Keep a bounded, metadata-free image for the public route and reserve the original for staff downloads.

How this was verified: The anonymous photo route reads the published registration with sudo() and serves profile_picture without requested dimensions, while this change preserves the original in that field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e0eb6de, on #440 (this PR is a duplicate of it). Without a size, the public route now serves 1920 px at most, as before this change; resizing also removes the metadata (GPS position, camera). The pages only use sized URLs. Test: a 4000 x 3000 JPG with GPS metadata comes back at 1920 x 1440 without metadata.

@danpa32

danpa32 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Changes are in 31f1e4e (plus a merge of the latest 18.0):

  • Single field: done. profile_picture is no longer capped and is written with image_no_postprocess, so it is kept as uploaded. profile_picture_original and its filename field are removed. The download link points to profile_picture, named after the participant when the message is sent. The pages were already requesting resized versions; the shop line image and the partner image keep their own caps. No migration: the field never reached 18.0 or stage.
  • DecompressionBombError: caught, gives the "too large" message (translated), with a test.
  • "My events" edit form: the check does run there. The wizard's related image field passes the uploaded value to the registration's write() unprocessed. Added a test through event.registration.form.
  • copy(): the duplicate keeps its picture, and the format check now honours SKIP_PROFILE_PICTURE_CHECK (test added).
  • accept in the form builder: not done. Odoo 18's website.form_field_binary template has no accept option, so it would need a core template override. The two forms in our templates keep their accept.
  • Mail template: the URL is now passed through render_values. The link goes to the backend, so it is meant for staff; portal followers would get an access error, as before.
  • Decoding several times / stored filename: mostly gone with the single field. The filename is computed from the participant's name and the stored file's mimetype.

9 tests pass. PR description updated.

@danpa32 danpa32 closed this Nov 4, 2026
@danpa32

danpa32 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Duplicate of #440, which was closed by mistake and is now reopened. The review and its follow-up are there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant