3.0.4 release and restriction on filenames

Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Mon, 2012-07-16 18:54

I do remember seeing special code restricting file naming convention to a certain style introduced in latest release
Could someone remind me what was changed? I have album with file names which now trigger Illegal_data_file_extension.

Second question, is there a way to automatically adjust file names to comply with new restrictions

Serge
_____________________________________________
Photo Gallery | GreyDragon Theme | Follow on Twitter

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Mon, 2012-07-23 18:22

bump

Serge
_____________________________________________
Photo Gallery | GreyDragon Theme | Follow on Twitter

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2012-07-23 19:02
Quote:
Illegal_data_file_extension

bharat committed a fix last night for filenames with multiple . in them
http://gallery.menalto.com/node/107102#comment-394437

-s

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Tue, 2012-07-24 01:33

Experimental snapshot was not updated with the fix

Serge
_____________________________________________
Photo Gallery | GreyDragon Theme | Follow on Twitter

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-07-24 03:48
 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Tue, 2012-07-24 17:45

Made change above, but it did not resolve the issue. Still getting the following
Probably something else is missing
Some of my files due to Unicode look like this

"__ __________________.jpg"
"______________-____ ________________ ________.jpg"
"______________________ 001_001.jpg"

and this was fine before, as this is how Gallery created them
In general, why ORM validation need to be performed on existing items
I would understand rules are applied when file is uploaded, but after?

2012-07-24 10:38:38 -07:00 --- error: ORM Validation has failed for items model
#0 /gallery3/system/libraries/ORM.php(755): ORM_Validation_Exception_Core::handle_validation('items', Object(Validation))
#1 /gallery3/modules/gallery/models/item.php(773): ORM_Core->validate(NULL)
#2 /gallery3/system/libraries/ORM.php(778): Item_Model_Core->validate()
#3 /gallery3/modules/gallery/libraries/MY_ORM.php(34): ORM_Core->save()
#4 /gallery3/modules/gallery/libraries/ORM_MPTT.php(79): ORM->save()
#5 /gallery3/modules/gallery/models/item.php(523): ORM_MPTT_Core->save()
#6 /gallery3/modules/gallery/models/item.php(276): Item_Model_Core->save()
#7 /gallery3/modules/gallery/models/item.php(173): Item_Model_Core->relative_path()
#8 /gallery3/themes/greydragon/libraries/MY_Theme_View.php(547): Item_Model_Core->file_url()
#9 /gallery3/themes/greydragon/views/album.html.php(44): Theme_View->get_thumb_link(Object(Item_Model))
#10/gallery3/system/libraries/View.php(318): include('...')
#11/gallery3/system/libraries/View.php(260): View_Core->load_view('...', Array)
#12/gallery3/modules/gallery/libraries/MY_View.php(75): View_Core->render(false, false, false)
#13/gallery3/system/libraries/View.php(226): View->render()
#14/gallery3/themes/greydragon/views/page.html.php(234): View_Core->__toString()
#15/gallery3/system/libraries/View.php(318): include('...')
#16/gallery3/system/libraries/View.php(260): View_Core->load_view('...', Array)
#17/gallery3/modules/gallery/libraries/MY_View.php(75): View_Core->render(false, false, false)
#18/gallery3/system/libraries/View.php(226): View->render()
#19/gallery3/modules/gallery/controllers/albums.php(77): View_Core->__toString()
#20 [internal function]: Albums_Controller->show(Object(Item_Model))
#21/gallery3/system/core/Kohana.php(331): ReflectionMethod->invokeArgs(Object(Albums_Controller), Array)
#22 [internal function]: Kohana_Core::instance(NULL)
#23/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#24/gallery3/application/Bootstrap.php(67): Event_Core::run('system.execute')
#25/gallery3/index.php(113): require('...')
#26 {main}
2012-07-24 10:38:38 -07:00 --- error: Validation errors: Array
(
[name] => illegal_data_file_extension
)

Serge
_____________________________________________
Photo Gallery | GreyDragon Theme | Follow on Twitter

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-07-24 19:20

Please update the thicket:
http://sourceforge.net/apps/trac/gallery/ticket/1897
with your findings.
Send Bharat a dump of your DB so he can replicate.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2012-07-24 20:43

Hm. A database dump would be helpful, but barring that, can you give me a listing of the names of the files in that album?
---
Problems? Check gallery3/var/logs
file a bug/feature ticket | upgrade to the latest code! | hacking G3? join us on IRC!

 
Gork

Joined: 2008-09-09
Posts: 85
Posted: Sat, 2012-08-18 03:44

@OP
I've just discovered tonight that, at least for me, spaces in filenames appear to be causing problems. I've posted my findings in a thread which bharat is also following:
http://gallery.menalto.com/node/107102

EDIT:
Never mind this post - though removing spaces from filenames fixed the issue I was having it was related to my firewall. I posted my my findings in the other thread.

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2466
Posted: Mon, 2012-07-30 16:43
bharat wrote:
Hm. A database dump would be helpful, but barring that, can you give me a listing of the names of the files in that album?

Sorry, cannot provide you with the dump.
Files are all as above - file names were in Russian and when uploaded they are converted into this form. Until 3.0.4 update, it was functioning for 3 years just fine.
Latest update have some restrictions which were introduced, but I suspect no upgrade path was incorporated to adjust any existing file notations.
if you could describe rules for file names it would be helpful to figure out which file is "wrong" from my end.

Serge
_____________________________________________
Photo Gallery | GreyDragon Theme | Follow on Twitter

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2012-08-04 19:14

Back from travelling - let's dig into this. All of those validation errors are generated in modules/gallery/models/item.php so let's figure out which one specifically you're tripping up on. I'm listing the four places where they happen below, all in the valid_name() function. Either you have more than one dot in a filename (line 810), you have a new file that's missing an extension (818 - probably not the issue), or you have a photo or movie that has an illegal extension (824, 830).

   807      // Do not accept files with double extensions, they can cause problems on some                                                            
   808      // versions of Apache.                                                                                                                    
   809      if (!$this->is_album() && substr_count($this->name, ".") > 1) {                                                                           
   810        $v->add_error("name", "illegal_data_file_extension");                                                                                   
   811      }                                                                                                                                         
   812                                                                                                                                                
   813      if ($this->is_movie() || $this->is_photo()) {                                                                                             
   814        $ext = pathinfo($this->name, PATHINFO_EXTENSION);                                                                                       
   815                                                                                                                                                
   816        if (!$this->loaded() && !$ext) {                                                                                                        
   817          // New items must have an extension                                                                                                   
   818          $v->add_error("name", "illegal_data_file_extension");                                                                                 
   819          return;                                                                                                                               
   820        }                                                                                                                                       
   821                                                                                                                                                
   822        if ($this->is_photo()) {                                                                                                                
   823          if (!in_array(strtolower($ext), legal_file::get_photo_extensions())) {                                                                
   824            $v->add_error("name", "illegal_data_file_extension");                                                                               
   825          }                                                                                                                                     
   826        }                                                                                                                                       
   827                                                                                                                                                
   828        if ($this->is_movie()) {                                                                                                                
   829          if (!in_array(strtolower($ext), legal_file::get_movie_extensions())) {                                                                
   830            $v->add_error("name", "illegal_data_file_extension");                                                                               
   831          }                                                                                                                                     
   832        }                                                                                                                                       
   833      }                                                                                                                                         

I suggest that you change the name of the error on those to something that tells you which line it's happening on and what the item id is and then we can figure out from the error what went wrong. Eg: $v->add_error("name", "illegal_data_file_extension {$this->id} at " . __LINE__);. Then generate the error and let's see what's in the logs.

---
Problems? Check gallery3/var/logs
file a bug/feature ticket | upgrade to the latest code! | hacking G3? join us on IRC!