Page MenuHomePhabricator

Diffusion -> show raw file doesn't always render text
Open, Needs TriagePublic

Description

If you browse to to a commit in diffusion and click View Options -> Show Raw File (Right) it sometimes displays the contents and sometimes jumps to a temporary file which you then have to download to view.

Consider the difference between the following to files from the same commit:
https://secure.phabricator.com/rPc4dfc097c8c979b557c6f16a641c7544e43525b8#bc342b5e
https://secure.phabricator.com/rPc4dfc097c8c979b557c6f16a641c7544e43525b8#a176644f

This might exist in differential too, unsure.

Event Timeline

sshannin updated the task description. (Show Details)May 12 2015, 6:37 PM
sshannin added a project: Diffusion.
sshannin added a subscriber: sshannin.
sshannin created this task.
sshannin raised the priority of this task from to Needs Triage.

The MIME type of these files is detected differently (text/plain vs text/x-php). We can probably force these to text/plain safely in all cases, but this has some security implications.

paks87 added a subscriber: paks87.Jul 7 2015, 1:31 PM
epriestley added subscribers: avivey, paladox.

You can also whitelist MIME types in files.viewable-mime-types as a workaround.

How can you support all files that can gitblit can view in raw.

And how would it be set.

avivey added a comment.Nov 4 2015, 7:26 PM

You need to have your admin add mime types to files.viewable-mime-types config.

Would you be able to do it in a config file or would it have to be done online throught the admin pref for phabricator if it is done through config then Wikimedia open source the file so that any one can propose to change what it does.

operation/puppet

avivey added a comment.Nov 4 2015, 7:44 PM

We are not Wikimedia. You need to discuss this with your admins. See https://www.mediawiki.org/wiki/Phabricator/Help .

ftdysa added a subscriber: ftdysa.Nov 4 2015, 7:45 PM

Specifically, you want to run the following command. This is just the default value + php.

./bin/config set files.viewable-mime-types '{
  "image/jpeg": "image/jpeg",
  "image/jpg": "image/jpg",
  "image/png": "image/png",
  "image/gif": "image/gif",
  "text/plain": "text/plain; charset=utf-8",
  "text/x-diff": "text/plain; charset=utf-8",
  "image/x-ico": "image/x-icon",
  "image/x-icon": "image/x-icon",
  "image/vnd.microsoft.icon": "image/x-icon",
  "audio/x-wav": "audio/x-wav",
  "application/ogg": "application/ogg",
  "audio/mpeg": "audio/mpeg",
  "text/x-php": "text/x-php"
}'

This is what it currently looks like

files.viewable-mime-types:

'image/jpeg': 'image/jpeg'
'image/jpg': 'image/jpg'
'image/png': 'image/png'
'image/gif': 'image/gif'
'text/plain': 'text/plain; charset=utf-8'
'text/x-diff': 'text/plain; charset=utf-8'
'image/vnd.microsoft.icon': 'image/x-icon'
'audio/x-wav': 'audio/x-wav'
'application/ogg': 'application/ogg'
'audio/mpeg': 'audio/mpeg'

https://phabricator.wikimedia.org/diffusion/OPUP/browse/production/modules/phabricator/data/fixed_settings.yaml

Thanks @epriestley and @avivey, we'll (WMF) fix the issue on our end :)

@paladox: debugging of our Phab install should happen in our Phab instance.

(For those curious and want to waste time, see https://phabricator.wikimedia.org/T117621 ) ;)

Hi the workaround works for mobile devices not desktops and laptops.

chad added a subscriber: chad.Nov 26 2015, 4:30 PM

@paladox who are you talking to, specifically, the upstream or Wikimedia?

I am asking phabricator. Since viewing raw php files doesn't work on deskop or laptop. So I am not sure what to set.

chad added a comment.EditedNov 26 2015, 4:51 PM

Then please follow our bug reporting guide: Contributing Bug Reports

Hi this files.viewable-mime-types doesn't seem to apply to desktop since testing using an iPhone 6 plus using safari and using a windows 10, edge and internet explorer the iPhone seems to register files.viewable-mime-types and follows what ever is set in it but on desktop it doesn't since for example going to https://phabricator.wikimedia.org/F3069835 on iPhone and then click download it lets you view the raw without needing to download but doing the same on desktop doesn't it downloads the file instead of viewing the file in raw.

epriestley moved this task from Backlog to Triage on the Diffusion board.Feb 2 2017, 4:08 PM