OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



yet more CSS uploads problems with OJS 2.4.2

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

yet more CSS uploads problems with OJS 2.4.2

Postby satificed » Wed Feb 05, 2014 11:46 am

Hi.

We are currently upgrading from 2.3.7 to 2.4.2.

And having the mimetype problems pointed out in these threads (and all the other relevant ones):

viewtopic.php?f=8&t=908
viewtopic.php?f=3&t=2391

And in the FAQ
http://pkp.sfu.ca/wiki/index.php/PKP_Fr ... d_properly

All of these suggestions appear to be for OJS < 2.4.2, except for this one:

viewtopic.php?f=8&t=10797

Which (unhelpfully) points the direction to searching the threads here.

I've tried the fixes of

Code: Select all
 if (function_exists('mime_content_type')) {


As well as removing initial comments (re: the FAQ solution) and pointing the config.inc.php file towards the appropriate mime.magic directory. The file permissions are all okay.

Help?
satificed
 
Posts: 7
Joined: Wed Feb 05, 2014 8:00 am

Re: yet more CSS uploads problems with OJS 2.4.2

Postby asmecher » Wed Feb 05, 2014 4:53 pm

Hi satificed,

Have you been able to ascertain which of the various methods that your server may support OJS is using to determine MIME types? These are implemented in lib/pkp/classes/core/String.inc.php in the mime_content_type function. The general plan here is 1) determine what method OJS is trying to use, then 2) debug that method. Without step 1 being done first, you'll be shooting in the dark.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Re: yet more CSS uploads problems with OJS 2.4.2

Postby JasonNugent » Thu Feb 06, 2014 7:35 am

Hi guys,

Ultimately, the fundamental problem with CSS is that there is no accepted mime type for it. In OJS 3.0, we have specific functionality in the way article galleys are displayed to force the mime type for CSS to text/css to get this to work. Apache and PHP both ship without entries in the mime database because mime detection on a plain text file that may or may not contain a string to match on is problematic. OJS 3.0 looks at the file extension in order to determine whether or not something is a CSS file. Alec, should I file a bug to back port that functionality to the 2.4 branch?

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 895
Joined: Tue Jan 10, 2006 6:20 am

Re: yet more CSS uploads problems with OJS 2.4.2

Postby asmecher » Fri Feb 07, 2014 1:54 pm

Hi Jason,

Got a commit link?

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Re: yet more CSS uploads problems with OJS 2.4.2

Postby JasonNugent » Tue Feb 11, 2014 12:54 pm

Hey Alec,

The commit log got a bit murky for this when the article galley plugins were generalized to the viewable file plugin category, but see e.g.:

https://github.com/pkp/ojs/blob/2a3d608 ... in.inc.php

starting on line 311 for the function, and 321 for the explicit mime type set when the file is marked as a style file for an HTML galley.

Cheers,
Jason
JasonNugent
Site Admin
 
Posts: 895
Joined: Tue Jan 10, 2006 6:20 am

Re: yet more CSS uploads problems with OJS 2.4.2

Postby asmecher » Tue Feb 11, 2014 12:59 pm

Hi Jason,

My concern around that kind of treatment is that we don't want to accidentally permit uploads of files that a) can be executed server-side (such as .php, especially for stuff that resides in the public files directory), or b) can be malicious client-side (such as .exe). If you're confident that neither is a risk, go for it.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Re: yet more CSS uploads problems with OJS 2.4.2

Postby JasonNugent » Tue Feb 11, 2014 1:22 pm

Hi Alec,

We can add an additional constraint for the original file extension in addition to the genre test for the style file. For 2.4, something like that would be necessary since the genre code is a 3.0-specific thing anyway. Would forcing the file extension along with the genre assuage your concern?

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 895
Joined: Tue Jan 10, 2006 6:20 am

Re: yet more CSS uploads problems with OJS 2.4.2

Postby asmecher » Tue Feb 11, 2014 3:04 pm

Hi Jason,

Yes, I think that would cover it. (Longer term, we'll be removing the public files directory entirely.)

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Re: yet more CSS uploads problems with OJS 2.4.2

Postby satificed » Wed Feb 12, 2014 6:40 am

Hi, Alec,

Sorry about the late reply, but I'm back at work.

For the 2.4.2 install we have:

Code: Select all
function mime_content_type($filename) {
      if (function_exists('mime_content_type')) {
         $result = mime_content_type($filename);
         // mime_content_type appears to return a charset
         // (erroneously?) in recent versions of PHP5
         if (($i = strpos($result, ';')) !== false) {
            $result = trim(substr($result, 0, $i));
         }
         return $result;
      } elseif (function_exists('finfo_open')) {
         $fi =& Registry::get('fileInfo', true, null);
         if ($fi === null) {
            $fi = finfo_open(FILEINFO_MIME, Config::getVar('finfo', 'mime_database_path'));
         }
         if ($fi !== false) {
            return strtok(finfo_file($fi, $filename), ' ;');
         }
      }


and this is the code for 2.3.7 (which is our current production, while I'm simply testing 2.4.2 for our upgrade):

Code: Select all
function mime_content_type($filename) {
      if (function_exists('mime_content_type')) {
         $result = mime_content_type($filename);
         // mime_content_type appears to return a charset
         // (erroneously?) in recent versions of PHP5
         if (($i = strpos($result, ';')) !== false) {
            $result = trim(substr($result, 0, $i));
         }
         return $result;
      } elseif (function_exists('finfo_open')) {
         $fi =& Registry::get('fileInfo', true, null);
         if ($fi === null) {
            $fi = finfo_open(FILEINFO_MIME, Config::getVar('finfo', 'mime_database_path'));
         }
         if ($fi !== false) {
            return strtok(finfo_file($fi, $filename), ' ;');
         }
      }


From my poking around, I do note that our server (Apache/httpd) supports both a mime.magic and the php fileinfo. I'm not quite sure how to tell which is being called... (Is there a particular log file that I could look at/post?)

Best,

nina
satificed
 
Posts: 7
Joined: Wed Feb 05, 2014 8:00 am

Re: yet more CSS uploads problems with OJS 2.4.2

Postby asmecher » Wed Feb 12, 2014 7:57 am

Hi Nina,

Try using the error_log function to insert entries in the error log. Put a different call in each branch of the code, upload a file to trigger the code, and then check the error log to see which branch was executed.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Re: yet more CSS uploads problems with OJS 2.4.2

Postby satificed » Wed Feb 12, 2014 11:52 am

Hey.

So....

The situation appears to have resolved itself?

I'm not sure how/why. But *some* css files are uploading, while others are not.

Code: Select all
/**
 * common.css
 *
 * Copyright (c) 2003-2006 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * Site-wide shared stylesheet.
 *
 * $Id: common.css,v 1.39 2006/07/01 17:36:16 alec Exp $
 */

/**
 * Common HTML elements
 */


Only CSS files with this commented header are being accepted.

I do thank everyone for trying to help and the responses.
satificed
 
Posts: 7
Joined: Wed Feb 05, 2014 8:00 am

Re: yet more CSS uploads problems with OJS 2.4.2

Postby asmecher » Wed Feb 12, 2014 12:04 pm

Hi satificed,

...and others have reported that CSS uploads only work *without* the code headers. Unfortunately it all depends on your server's particular MIME magic file, and regardless, these don't play particularly well with CSS. The OJS 3.0 solution will be less problematic. Meanwhile, glad you've got it going.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9214
Joined: Wed Aug 10, 2005 12:56 pm

Re: yet more CSS uploads problems with OJS 2.4.2

Postby JasonNugent » Wed Mar 12, 2014 11:00 am

FYI this will be fixed in the next version of OJS (probably 2.4.4). For now, you can use the commit in the bug report to fix it in the interim if you like. http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=8607

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 895
Joined: Tue Jan 10, 2006 6:20 am


Return to OJS Technical Support

Who is online

Users browsing this forum: Astro, Baidu [Spider], Yahoo [Bot] and 2 guests