Skip to content

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Dec 3, 2025

Forward-Port-Of: #238151

`_odoo_guess_mimetype` requires bytes upfront as `_Entry.signatures`
are lists of bytes, thus `bin_data.startswith(signature)` requires
that `bin_data` be `bytes`.

Forthe libmagic version this is a bit more dodgy: `magic` accepts
`str` (and encodes under the hood if so) for Python 2 compatibility
reasons, but the `guess_mimetypes` wrapper will trigger an unhelpful
warning if libmagic recognizes a zip or ole file.

Update the libmagic version to reject str inputs.

X-original-commit: e4030de
`IrAttachment.create` first `_check_contents` which
`_compute_mimetype` which `guess_mimetype` which formerly decoded an
`str` input and now errors, *then* encodes the `raw` anyway in order
to checksum and index it.

Decode `raw` upfront if present.

While at it decode and move `datas` to `raw` that way downstream
functions (`_compute_mimetype`, `_postprocess_contents`) have no need
to repeatedly deal with and b64decode `datas`.

X-original-commit: ccd342f
@robodoo
Copy link
Contributor

robodoo commented Dec 3, 2025

Pull request status dashboard

@fw-bot
Copy link
Contributor Author

fw-bot commented Dec 3, 2025

@xmo-odoo this PR targets master and is the last of the forward-port chain.

To merge the full chain, use

@robodoo r+

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Dec 3, 2025
@xmo-odoo
Copy link
Collaborator

xmo-odoo commented Dec 3, 2025

@robodoo r+

robodoo pushed a commit that referenced this pull request Dec 3, 2025
`_odoo_guess_mimetype` requires bytes upfront as `_Entry.signatures`
are lists of bytes, thus `bin_data.startswith(signature)` requires
that `bin_data` be `bytes`.

Forthe libmagic version this is a bit more dodgy: `magic` accepts
`str` (and encodes under the hood if so) for Python 2 compatibility
reasons, but the `guess_mimetypes` wrapper will trigger an unhelpful
warning if libmagic recognizes a zip or ole file.

Update the libmagic version to reject str inputs.

X-original-commit: e4030de
Part-of: #238485
Related: odoo/enterprise#101188
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
robodoo pushed a commit that referenced this pull request Dec 3, 2025
`IrAttachment.create` first `_check_contents` which
`_compute_mimetype` which `guess_mimetype` which formerly decoded an
`str` input and now errors, *then* encodes the `raw` anyway in order
to checksum and index it.

Decode `raw` upfront if present.

While at it decode and move `datas` to `raw` that way downstream
functions (`_compute_mimetype`, `_postprocess_contents`) have no need
to repeatedly deal with and b64decode `datas`.

closes #238485

X-original-commit: ccd342f
Related: odoo/enterprise#101188
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
@robodoo robodoo added the 19.1 label Dec 3, 2025
@robodoo robodoo closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

19.1 forwardport This PR was created by @fw-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants