"Show Source" frequently fails
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 348
- Avg merge
- 12h 28m
- Merged PRs (30d)
- 91
Description
Steps to reproduce
- Open a message
- Select "Show source" action button
Expected behavior
The source of the message should be shown.
Actual behavior
Throws a 500:
Apache log:
"GET /apps/mail/api/messages/141034/source HTTP/2.0" 500
Nextcloud log:
{"reqId":"fZXTBIIsQKW1h5usNz1V","level":3,"time":"2023-09-20T20:33:07+00:00","remoteAddr":"<IP>","user":"<user>","app":"index","method":"GET","url":"/apps/mail/api/messages/141034/source","message":"Malformed UTF-8 characters, possibly incorrectly encoded","userAgent":"Mozilla/5.0 (Android 13; Mobile; rv:109.0) Gecko/117.0 Firefox/117.0","version":"27.1.0.7","exception":{"Exception":"JsonException","Message":"Malformed UTF-8 characters, possibly incorrectly encoded","Code":5,"Trace":[{"file":"<documentroot>/lib/public/AppFramework/Http/JSONResponse.php","line":66,"function":"json_encode","args":[[null],4194305]},{"file":"<documentroot>/lib/private/AppFramework/Http/Dispatcher.php","line":182,"function":"render","class":"OCP\AppFramework\Http\JSONResponse","type":"->","args":[]},{"file":"<documentroot>/lib/private/AppFramework/App.php","line":183,"function":"dispatch","class":"OC\AppFramework\Http\Dispatcher","type":"->","args":[["OCA\Mail\Controller\MessagesController"],"getSource"]},{"file":"<documentroot>/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\AppFramework\App","type":"::","args":["OCA\Mail\Controller\MessagesController","getSource",["OC\AppFramework\DependencyInjection\DIContainer"],["141034","mail.messages.getSource"]]},{"file":"<documentroot>/lib/base.php","line":1068,"function":"match","class":"OC\Route\Router","type":"->","args":["/apps/mail/api/messages/141034/source"]},{"file":"<documentroot>/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"<documentroot>/lib/public/AppFramework/Http/JSONResponse.php","Line":66,"CustomMessage":"--"}}
Mail app version
3.4.0
Mailserver or service
dovecot imapd
Operating system
openSUSE Tumbleweed
PHP engine version
PHP 8.2
Web server
Apache (supported)
Database
PostgreSQL
Additional info
From the mail source:
Content-Type: text/plain; charset=Cp1252 Content-Transfer-Encoding: 7bit
The offending byte might be "FC" for "ü" which is correct but neither UTF-8 nor 7bit.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the MessagesController getSource endpoint shown in the trace and follow how the message source reaches JSONResponse.php. Reproduce the request with the attached message_example.txt, then inspect handling of the Cp1252 source and malformed UTF-8. Done means Show source returns the message source instead of a 500 for this input, with a regression test covering the encoding case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100