68 Commits

Author SHA1 Message Date
shadlaws
8d0e1b4c4d #2059 - Add album name sanitizing similar to photo/movie filename sanitizing.
- added legal_file::sanitize_dirname(), analogous to sanitize_filename.
- revised item model to use new function when adding or updating an album.
- added some legal_file unit tests.
- revised some item model unit tests.
2013-03-13 10:07:58 +01:00
shadlaws
ed20798b99 #2057 - Revise item name and slug validation - backslashes, refactor, error messages.
- disallowed backslashes in item validation.
- refactored the validation logic in the item model a bit.
- added no_backslash error messages in edit album/photo/movie forms.
- fixed error messages in add album forum (some missing, some text different from edit)
- added unit tests
- updated to v58 to correct any existing backslashes in item names
2013-03-12 12:14:34 +01:00
Bharat Mediratta
dc7bf9486f Follow-on for #2043. Fix some tests that made bad assumptions about
the state of the world.  These were uncovered when we ran the tests on
Travis which runs the tests in a different order than what I (and
apparently others) use on their dev boxes.
2013-03-06 14:33:24 -05:00
shadlaws
d04a6fc87d #2001 - Make filename sanitizing more consistent.
- legal_file - added sanitize_filname() to sanitize photo/movie filenames.
- admin_watermarks - revised add() to use new function.
- item model - added _process_data_file_info() to validate the data file, get its metadata, and sanitize the item name.
- item model - revised save() for new items to use _process_data_file_info *before* the slug is checked.
- item model - revised save() for updated items to use _process_data_file_info.
- item model - revised save() for updated items to sanitize name if changed.
- uploader - removed call to smash_extensions (item model does this when it calls sanitize_filename).
- Legal_File_Helper_Test - added unit tests for sanitize_filename.
- Item_Model_Test - revised existing unit tests based on changes.
- Item_Model_Test - added new unit tests for names with legal but incorrect extensions.
- Averted take over by HAL with fix #2001...
2013-02-12 00:37:33 +01:00
shadlaws
0312d1b071 #1994 - Make get_file_metadata throw an exception if photo or movie is unidentifiable/illegal.
- photo & movie helpers: modified to throw exceptions when file is known to be unidentifiable/illegal.
- item model: revised to work with exceptions and be more explicit when the data file is invalid.
- item model: removed duplicate get_file_metadata call for updated items.
- admin_watermarks controller: revised to work with exceptions (really cleans up logic here).
- graphics helper: revised to handle invalid placeholders (a nearly-impossible corner case, but still...).
- photo & movie helper tests: revised to work with exceptions, added new tests for illegal files with valid extensions.
- item model tests: revised to work with exceptions, added new tests for illegal files with valid extensions.
2013-02-08 13:51:41 +01:00
shadlaws
1ae1165229 Follow-on to 949b8cda14 for #1982.
- Add extra condition to Item_Model_Test::urls_test to test cache busters of missing files.
- Previous commit fixes unit test for empty album url, but now no test checks missing files.
2013-02-06 10:24:06 +01:00
shadlaws
949b8cda14 Follow-on to f83ed5f871 for #1982.
- Fix unit test for album url since empty albums now have thumbnails.
2013-02-02 10:02:37 +01:00
shadlaws
cc2aed656c #1946, 1947 - Make altered names/slugs more user-friendly, make conflict-finding code check filenames with no extensions
- Reduced from four places that alter names/slugs to two (one to populate empty slugs, one to handle conflicting names/slugs).
- For empty slugs, fill with generic human-readable name (e.g. "photo") instead of random value.
- For conflicting names/slugs, add suffix that's sequential (e.g. "-01"), only using random after 99 conflicts.
- Made conflict-finding code check filenames with no extensions.
- Renamed _randomize_name_or_slug_on_conflict to _check_and_fix_conflicts.
- Added unit tests.  Also cleaned up existing unit tests to reflect new logic and removed a redundant test.
- Added installer logic to correct existing items now considered in conflict.
- Revised gallery_task to look for duplicate names based on new criteria.
2013-01-26 08:38:31 +01:00
shadlaws
126727b4f2 #1955 - Make unit test photos unique.
- Added test::random_unique_photo and test::random_unique_photo_unsaved to uniquify test photos.
- Uniquified the black dot of test.jpg by coloring it with the six-digit hex code already used to name the random photos (e.g. "name_a48801.jpg").
- Modified four tests in Item_Model_Test that check photo file contents to use new functions to guarantee uniqueness.
2013-01-24 15:56:13 +01:00
Bharat Mediratta
9ba9f39531 Add a "can_add" permission bit similar to the "can_edit" bit to the RESTful array
representation of Item_Model.  Fixes #1903.
2013-01-23 18:24:31 -05:00
Bharat Mediratta
d45a737779 Update copyright to 2013. Fixes #1953. 2013-01-21 01:22:01 -05:00
shadlaws
14b02a5b12 #1950 - Replace bogus file overwrites from item model unit test.
- modified rename_photo_test, rename_album_test, move_album_test, move_photo_test
- unit tests still test file system integrity and pass
2013-01-20 10:01:41 +01:00
Bharat Mediratta
d04080c7be Follow-on to 94b26e506c - make the new legal_file
functions more robust when passed an unknown extension.  Fixes Item_Model_Test.
2013-01-17 15:05:46 -05:00
Bharat Mediratta
6d9d6a2e5d Allow albums to have two (or more) dots in the name. Fixes #1897. 2012-07-21 15:01:31 -07:00
Bharat Mediratta
9e2ea2ffed Smash multiple extensions down into a single one when accepting file
uploads.  Fixes #1872.
2012-05-17 20:25:27 -07:00
Bharat Mediratta
801c9a98e4 Fix #1846. 2012-05-05 18:52:44 -07:00
Bharat Mediratta
bf2bb3e1ea Update copyright to 2012. #1822 2012-02-27 09:48:23 -08:00
Chad Parry
0672c8f83f Polishing the rawphoto changes, including adding some tests.
Squashed commit of the following:

commit 945316a8c220b12adb687c896bcc5e86f99f46a4
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Jul 21 01:11:13 2011 -0600

    Add a test for the sunny-day scenario where a rule changes a data file's MIME type.

commit 4ee1ee000c8f4d8ebaae66f637bc71080486fd73
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Jul 21 00:49:47 2011 -0600

    Ensure that a third-party cannot swap out a legitimate photo with an unsafe file type.

commit 7dd0105bfc59c150e5640e693778f51bbaa44eab
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Jul 21 00:48:19 2011 -0600

    Update the MIME type and other meta-data when a new data file is provided.

commit 5a8844c7947b21cf658f22cc61f20ffa9e8f07f2
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Jul 21 00:30:01 2011 -0600

    Remove a unit test that no longer applies. Replacement data files are allowed to have different MIME types.

commit 0de9c6283ce4f5773cad8e92b6785d6a1f7b5e46
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Jul 21 00:27:45 2011 -0600

    If one rule fails, then abort processing, rather than trying to proceed to subsequent rules.

commit 41d379c2b777ae7b3a11f528971228e234f8976f
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Jul 21 00:10:10 2011 -0600

    Replace an overly-complicated regular expression with a simple in_array, at Bharat's suggestion.

commit 1b3f7111d4c2607baaa2da0aab3b501f2d9a1426
Merge: 8f7904a 403f64b
Author: Chad Parry <github@chad.parry.org>
Date:   Wed Jul 20 21:02:56 2011 -0600

    Merge branch 'master' into rawphoto

commit 8f7904ab62c71a7e4ee68762f936030b4dcb4ea1
Merge: e950573 771de0a
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Jun 25 14:12:39 2011 -0600

    Merge branches 'master' and 'rawphoto' into rawphoto

commit e95057337996351e49915d9f85d007d50103a4be
Author: Chad Parry <github@chad.parry.org>
Date:   Wed Jun 15 20:24:18 2011 -0600

    Merge branches 'rawphoto-squash' and 'rawphoto' into rawphoto
2011-07-21 01:12:26 -06:00
Bharat Mediratta
423daa52d5 Update copyright to 2011. 2011-01-21 23:01:06 -08:00
Bharat Mediratta
9f3c6e4bee Update test to match change in Item_Model::as_restful_array made in
7e31f97b4c for #1536.
2010-12-28 22:00:25 -08:00
Bharat Mediratta
cd48b89f31 Consolidate all the random code into a random helper that offers:
random::hash()
  random::string()
  random::percent()
  random::int()

So that we don't have lots of different ways to get random values all
over the code.  Follow-on to #1527.
2010-12-15 14:57:00 -08:00
Bharat Mediratta
45c63f4d11 Use mt_rand() instead of rand() since it provides better portability.
Fixes #1527.
2010-12-15 12:48:56 -08:00
Bharat Mediratta
79740a2c77 Move photo/movie file extension validation into the model. Fixes #1524. 2010-12-14 21:19:25 -08:00
Bharat Mediratta
e87c502ede Tie the image cachebuster to the file mtime instead of
Item_Model::$updated since we want the url to be stable whenever
possible.  Fixes #1482.
2010-11-09 12:48:07 -08:00
Bharat Mediratta
f84c4a6192 Uniqify the name and slug when we move an item to a new location with
a conflict.  This fixes #1364.
2010-09-11 23:37:12 -07:00
Bharat Mediratta
dfb095a262 Add the ability to replace the source data file in Item_Model::save().
Refactor the rotate code in Quick_Controller to replace the data file,
and then have gallery_event::item_updated_data_file() pick up after
the change is saved, rebuild the image and handle album covers.  This
is much more portable than before and it will allow any mechanism (eg:
REST) to replace the source image.
2010-08-07 22:18:28 -07:00
Bharat Mediratta
e3535349ab Revert "Add a "convert_ids" parameter to Item_Model::as_restful_array(), which"
This reverts commit 98fce83de5.

Conflicts:

	modules/gallery/tests/Item_Model_Test.php
2010-06-15 20:25:35 -07:00
Bharat Mediratta
3dacafb718 Revert the "preserve_ids" global query parameter. We decided that it was a
bad idea.

This reverts commit 6425d41edd.
2010-06-09 20:49:32 -07:00
Bharat Mediratta
b40057283e Add a "can_edit" field to the Item_Model's REST output. It's
applicable to the current user.
2010-06-08 20:59:24 -07:00
Bharat Mediratta
6425d41edd Add a "preserve_ids" global query parameter for REST requests that
indicates that we shouldn't opportunistically convert ids into REST
urls.
2010-06-07 23:12:52 -07:00
Bharat Mediratta
98fce83de5 Add a "convert_ids" parameter to Item_Model::as_restful_array(), which
we can turn on with a query parameter.
2010-06-07 22:23:46 -07:00
Bharat Mediratta
9affa8ebbd Pick a new album cover when the photo that's the current cover is
deleted.  Fixes ticket #1083.
2010-05-10 22:11:59 -07:00
Bharat Mediratta
4068e80f06 Update test to reflect slug change in 78db1bb339 2010-04-22 22:24:44 -07:00
Bharat Mediratta
78db1bb339 Fix a bug where if the file name is composed of entirely illegal
characters, we'll get an empty slug.  Partial fix for #1086.
2010-04-04 14:27:39 -07:00
Bharat Mediratta
c3c2b45280 Update the copyright to 2010. It's only 3 months into the year :-) 2010-03-03 10:15:34 -08:00
Bharat Mediratta
d29028c4ea Add Item_Model::as_restful_array() for convenience. 2010-01-30 23:36:11 -08:00
Bharat Mediratta
212633d05a Prevent accidentally deleting the root album. 2010-01-27 21:52:18 -08:00
Bharat Mediratta
46d4d778ad Remove debug code. 2010-01-20 23:33:09 -08:00
Bharat Mediratta
feefdfd533 Stop using MY_ORM::original(). 2010-01-20 22:51:18 -08:00
Bharat Mediratta
995faaa27f Stop using MY_ORM::original(). It's got very odd semantics and we are
not capturing all cases for setting and resetting $original, which
leads to some weird and hard to reproduce behavior.

Instead, if we need the original just reload it from the database.
This may result in a somewhat excessive load in places, but we'll have
to fix that in a later optimization pass.
2010-01-20 22:45:19 -08:00
Bharat Mediratta
76da85a1a0 Extend Gallery_Unit_Test_Case instead of Unit_Test_Case. 2010-01-19 22:38:19 -08:00
Bharat Mediratta
e39c8df19f Fix some validation checks to check to see if the original was loaded
before deciding whether or not we changed a value.

Change valid_name to be cascading, not parallel.
2010-01-19 21:20:36 -08:00
Bharat Mediratta
4418993db9 Add slug_is_url_safe_test() 2010-01-18 23:38:39 -08:00
Bharat Mediratta
9eedf5c207 switch to test::starts_with(). 2010-01-18 22:55:16 -08:00
Bharat Mediratta
cfc0f3d0c0 Minor test cleanup. 2010-01-18 22:51:40 -08:00
Bharat Mediratta
b4e6834a28 Added move_album_fails_wrong_target_type_test() 2010-01-18 21:14:43 -08:00
Bharat Mediratta
677fb08002 Updated tests to match what the expected new API for moving items.
Now to move an item, you just change its parent_id.
2010-01-18 21:12:26 -08:00
Bharat Mediratta
38c13760af Switch to using test::random_name() to avoid integer names.
Fix up rename_photo_test.
2010-01-18 20:14:09 -08:00
Bharat Mediratta
92ed5d45e6 In item_rename_fails_with_existing_name_test switch validate() to
save() now that Kohana ticket #2504 is resolved.
2010-01-18 12:56:49 -08:00
Bharat Mediratta
ebb909625c Merge branch 'master' into bharat_dev 2010-01-18 12:54:26 -08:00