Jump to content

Image Upload / Resize Issues - pathname may not contain double slash “//”


sivsy
 Share

Recommended Posts

After upgrading two development sites from version 3.0.114 to the now Master 3.0.123, I am now encountering issues with image uploads / resizing when trying to add any image (that incidentally resizes to a width of 800px on upload)  and also after changing some code to set a new width on existing images that are output as thumbnails within a slideshow thumbnail navigation.

The error states the following - pathname may not contain double slash “//”

If I revert back to my previous version of the 'wire' directory, all is ok.

I am running IIS7 on a Windows Server (for development) with files residing on a NAS box on the network - Sites in IIS7 are mapped to the NAS box network name ie. \\ALPHA\Development\.... and IP address/port number combinations used to view the sites - this is the development set up that has been running for a number of years and currently runs over 20 ProcessWire sites with no issues (certainly up to version 3.0.114)

Two of the errors I get are:

pathname may not contain double slash “//” (in \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\modules\Inputfield\InputfieldFile\InputfieldFile.module line 791)

The above is when adding an image to a page in Admin.

and ...

Error: Exception: pathname may not contain double slash “//” (in \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\WireFileTools.php line 486) #0 \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\WireFileTools.php(821): ProcessWire\WireFileTools->allowPath('//ALPHA/DEVELOP...', false, true) #1 \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\WireTempDir.php(353): ProcessWire\WireFileTools->filePutContents('//ALPHA/DEVELOP...', 1548003024) #2 \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\WireTempDir.php(164): ProcessWire\WireTempDir->mkdir('//ALPHA/DEVELOP...', true) #3 \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\PagefilesManager.php(623): ProcessWire\WireTempDir->get() #4 \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\Pageimage.php(703): ProcessWire\PagefilesManager->getTempPath() #5 \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\Pageimage.php(552): ProcessWire\Pageimage->___size(100, 0, Array) #6 \\ALPHA\DEVELOPMENT\NOL Network\Website\wire\core\Pageimage.php(865): ProcessWire\Pageimage->size(

when an existing image is trying to resize on the fly after changing code to display images with a defined width.

I noticed that in WireFileTools.php there is a reference on line 414 in the notes near to where this error occurs that says '@since 3.0.118'

 

Has anyone come across this issue at all or does anyone have an idea about how I can resolve it? 

 

Link to comment
Share on other sites

This is actually most likely a problem with allowPath() method in WireFileTools.php, introduced in an attempt to fix some issues with temp directory (if I remember correctly). All backslashes are replaced with forward slashes so your UNC notation \\host-name\share-name\file_path becomes //host-name/share-name/file_path. Double forward slashes are recognized as URL or some extra slashes, and an exception is thrown. The solution would be not to use UNC notation but rather map a drive to your share and use a drive letter.

  • Like 1
Link to comment
Share on other sites

Thanks for the suggestion @matjazp 

I do already have a drive letter mapped to the NAS share on the Windows Server so changed the settings in IIS for one of the sites to use this instead but then encountered a 500 Server Error in the browser.

I'm no expert in Web Server configuration and have been using the UNC notation for all IIS served sites for many, many years without issue and don't really want to change the way I configure sites in IIS if I don't have to.

I may just have to work with processwire versions prior to 3.0.118 for all new sites going forward.

Live sites shouldn't be an issue as all my client's sites are hosted with Linux.

Link to comment
Share on other sites

11 hours ago, sivsy said:

I may just have to work with processwire versions prior to 3.0.118 for all new sites going forward.

Hello, it doesn't sound like a solution to me. Probably this problem should be posted in the right GitHub issue: https://github.com/processwire/processwire-issues/issues?utf8=✓&q=windows+path whichever it is...

 

  • Like 2
Link to comment
Share on other sites

Hi @matjazp - sorry I haven't responded to your last post, I have been away from the work office for a few days.

I'm not too sure how to share my configuration but have attached a screenshot of the Advanced settings for the site in IIS7

I have changed the Physical Path from a UNC one ie. \\ALPHA\Development\NOL Network\Website to a mapped drive equivalent. The Path Credentials are set to the admin server logon (this is the only user login I use on this server) This is set using the 'Specific User' option. All works okay with UNC notation but I get 500 Server Error when browsing if I use the mapped drive - I have tried changing to the 'Application User (pass through)' option, but this does not work.

The share I am using is located on a Linux NAS (A Buffalo Terastation which has a different username/login to the NAS admin control panel - irrelevant I guess for directory permissions)

I am unsure what I need to do within the site settings to allow the use of a mapped drive instead of UNC - searching other forums (IIS.net, Microsoft etc.), the general consensus is to not use mapped drives but use UNC, but this is likely the cause of the issues I get with PW version 3.0.118 or newer so I cannot see how this could be resolved. In the longer term I would be looking to replace my IIS web server with a LAMP set up for development, but this will be some way off.

iisnoldir.jpg

Link to comment
Share on other sites

I tested here and the problem is indeed in WireFileTools.php, these lines:

        if(strpos($pathname, '//') !== false) {
            // URLs or accidental extra slashes not allowed
            if($throw) throw new WireException('pathname may not contain double slash “//”');
            return false;
        }

I commented them and image upload is working. Of course, the test for // is there for a purpose, so just commenting it is not the best solution. You are encouraged to report the issue at https://github.com/processwire/processwire-issues/issues

OT: I found that using UNC considerably slowed down the whole web site. Maybe it's just something in my config, I simply created a test share on my own PC.

Link to comment
Share on other sites

Many thanks @matjazp for your time looking at this.

Yes, I will report this issue on github.

I find using UNC on my Windows Web Server excruciatingly slow sometimes when browsing to my development sites but once uploaded to live with my hosting providers, my ProcessWire sites are extremely quick loading, even without using template caching etc.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...