View Issue Details

IDProjectCategoryView StatusLast Update
0009894mantisbtotherpublic2009-01-15 11:25
Reporterjreese Assigned Tojreese  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Target Version1.2.0a3Fixed in Version1.2.0a3 
Summary0009894: Inconsistent uses of file extension configuration settings.
Description

I found this issue while investing issue 0009890. We have three separate configuration values for selecting what file extensions can be viewed inline, shown as text, etc:

   # Extensions for text files that can be expanded inline.
$g_preview_text_extensions = array( 'txt', 'diff', 'patch' );

# Extensions for images that can be expanded inline.
$g_preview_image_extensions = array( 'bmp', 'png', 'gif', 'jpg', 'jpeg' );

# list of filetypes to view inline. This is a string of extentions separated by commas
# This is used when downloading an attachment.  Rather than downloading, the attachment
# is viewed in the browser.
$g_inline_file_exts = 'gif,png';</pre>

It seems to me that:

  • The duplication of image extensions is confusing and unnecessary
  • The difference in definition (array vs string) is also confusing

To add to all this, when viewing the list of bug attachments, the following configuration setting is improperly checked:

   # Specifies the maximum size (in bytes) below which an attachment is 

previewed in the bug view pages.

# To disable this feature, set max size to 0.
$g_preview_attachments_inline_max_size = 0;</pre>

When listing attachments, the code only checks that 'file_size <= max_size', and ignores the documented (and default) use of 0 as meaning 'no limit'. This should be rectified in core/file_api.php (1.1.x) and core/print_api.php (1.2.x).

TagsNo tags attached.

Relationships

parent of 0009928 closedjreese Inconsistent uses of file extension configuration settings. 

Activities

jreese

jreese

2008-11-25 15:05

reporter   ~0020041

Reminder sent to: giallu, grangeway, thraxisp, vboctor

Since most of Mantis predates my time with the project, I want to make sure that I'm coming from a sane point of view on this topic. Can you all provide your opinions/feedback/knowledge on this bug?

Thanks.

giallu

giallu

2008-11-25 18:30

reporter   ~0020053

surely, there's something fishy here...

I agree that $g_inline_file_exts and $g_preview_image_extensions should be reviewed and, if appropriate, consolidated.
At first glance, the $g_inline_file_exts should go away entirely, as I can't really see the value in seeing an image when I click on a "download" link.

However, I note that my poor english interpret:

Specifies the maximum size (in bytes) below which an attachment is

previewed in the bug view pages.

To disable this feature, set max size to 0.

as:
set it to 0 to disable the preview feature, not the limit feature, so probably we just need to clarify the remark.

jreese

jreese

2008-11-25 23:13

reporter   ~0020056

Hmm, I read that as:

  • The "feature" is selecting a maximum size for attachments that should be preview-able.
  • Disabling the feature, to me, means disabling the maximum size, such that there is no size limit to what files can be previewed.

Surely if you didn't want any attachments to be shown inline or with a preview, you could either:

  • Set both *_extension arrays to contain no items, or
  • Set the maximum size to '1' such that any file will by necenssity be greater than 1 byte, thereby excluding all files

I personally think it makes much more sense to allow "some or no limit" than to only allow a choice of some arbitrary maximum size...

vboctor

vboctor

2008-11-26 00:52

manager   ~0020058

I think the inline file extensions and the preview images are two different things and they should probably remain separate. For example, an admin may disable preview for images but have them show inline when clicked. Or an admin may configure images + other files to show inline (e.g. text files / html).

However, I agree on the following:

  1. The default for inline_file_exts should be revised to include all images.
  2. We should have a consistent way to represent a list of extensions for all settings. We may even support both string / array, but we should be consistent.
  3. The documentation of the configuration options should be enhanced to remove any possible confusion.

As for the preview disabling, we could do it through size or through setting the extensions to none. However, given we already had this option and it is working via the size, I see no reason to change it.

As for unlimited size for preview, we could use -1 for that. However, I think getting the admin to think about the max limit is not a bad thing. For example, do they want their users to preview images that are 1-5MB?

jreese

jreese

2008-12-02 13:04

reporter   ~0020188

Retargetting the primary purpose of this issue for 1.2.x.

jreese

jreese

2008-12-02 13:11

reporter   ~0020189

I think probably the "best" solution in my opinion is to:

  • drop $g_inline_file_exts
  • change file_download.php to use a combination of $g_preview_image_extensions and $g_preview_text_extensions in place of $g_inline_file_exts

To me, this makes more sense, and is less prone to getting out of sync when changing configs. I can't really think of any valid reason why you would want to show attachments inline when viewing the bug, or vice versa, and I think the added simplicity of removing the repetitive config options is a win.

Thoughts?

Related Changesets

MantisBT: master e0d3b361

2008-11-27 04:58

vboctor


Details Diff
Fixes 0009905: Simplify the process of moving the attachments folder. Affected Issues
0009894, 0009905
mod - core/print_api.php Diff File
mod - docbook/adminguide/en/configuration.sgml Diff File
mod - config_defaults_inc.php Diff File
mod - core/file_api.php Diff File
mod - core/utility_api.php Diff File
mod - file_download.php Diff File

MantisBT: master-1.1.x 739397fe

2008-12-02 13:52

jreese


Details Diff
Fix 0009894: inconsistent set of file extensions for attachments. Affected Issues
0009894, 0009928
mod - config_defaults_inc.php Diff File