The scribble module is intended to provide drupal site with a possibility to add pages that contain a drawing canvas. Visitors with the corresponding permission can then draw on this canvas and save the changes they drew on the canvas.

The idea is to provide some kind of social art sites. You could also think of a plaster on which different people write their greetings and paint their recovery wishes when u broke your leg.

The module is entity based and makes use of the entity API. A scribble entity contains information about the dimensions of the canvas, the available brushes for drawing, the background color and of course also the image snapshots.
The term snapshot describes an image that gets created once a user saves his drawing on the canvas to an image file. There are snapshots which contain only the changes of a saved drawing in a tranparent png, as well as the merged images onto which a new snapshot will be merged.

I couldn't find any similar projects on drupal.org.

The project can be found at https://drupal.org/sandbox/s_leu/2126163

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/s_leu/2126163.git scribble

CommentFileSizeAuthor
#30 scribble_save_ajax_access.patch1.83 KBs_leu

Comments

s_leu’s picture

Issue summary: View changes
s_leu’s picture

Issue summary: View changes
s_leu’s picture

Issue summary: View changes
s_leu’s picture

Added review for Service API module at https://drupal.org/comment/8251341#comment-8251341

s_leu’s picture

Added a review for the Entityqueue Scheduler module at https://drupal.org/comment/8251441#comment-8251441

s_leu’s picture

Status: Active » Needs review

Added a review of the rublon sandbox module at https://drupal.org/comment/8251469#comment-8251469

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxs_leu2126163git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

ram4nd’s picture

Something besides pareview.sh issues.

  • Your project page needs description.
  • Remove master branch http://drupal.org/empty-git-master.
  • Implement variable_del to hook_uninstall.
  • Why do you use DIRECTORY_SEPARATOR???
  • scribble.module - line 334 use abstraction layer instead of query.
s_leu’s picture

Status: Needs work » Needs review

Applied the proposed changes and added a description to the project page. I can't find a good example to prevent the last remaining error that is reported by pareview.sh though.

chalk’s picture

@s_leu, good work!

But:

  • Remove from scribble.js "console.log('BLABLA');" ;)
  • It's recommended to move all theme functions with HTML to .theme.inc or .tpl.php. May be you can use theme_html_tag() in your theme_scribble_brush_options()?
  • For directory creating there's Drupal function file_prepare_directory().
chalk’s picture

Status: Needs review » Needs work
yashsharma01’s picture

Hi s_leu,
This module contain drupal_mkdir($path, 0777); many times in the function scribble_prepare_folders($scribble_id) at line 451.
I think this is security issues to create directory with permission 0777 on the server any where, if i am right? Will it work with maximum 0775 permission?

Thanks,
Yash

s_leu’s picture

Status: Needs work » Needs review

Thanks Chalk and yashsharma01. I made the suggested changes:

  1. removed the console.log statement
  2. moved the theme function for the brushes into a separate template file
  3. used file_prepare_directory, which also solves the issue with the 777 permissions as both of you suggested

Hope the module is now ready to be published :)

alinouman’s picture

Hi s_leu,
1- Your configure link is wrong in info file configure = admin/config/user-interface/scribble It should be admin/config/media/scribble

2- The images that are coming in slideshow are quite heavy a 500x500 is of size 758 kb it can be made of low size possibly also in jpg for more compression.

3-Background color of canvas not working in my side. Although i have given it in settings form.

alinouman’s picture

Status: Needs review » Needs work
s_leu’s picture

Hi alinoum

Thanks for the review, nice catches. Regarding point 3 i have to say that it was never intended to change the color once you added a scribble. It's a feature that might follow but for now, the background color can only be set when adding a new scribble entity and this is working. I added a condition to deny access to the field when editing an entity.

I changed the configure path accordingly. The thing with the big png images is indeed a serious issue that needs some work. I will try to use jpg for the images and use png only for the snapshots. Thanks again.

s_leu’s picture

Status: Needs work » Needs review

I finally added support for image quality and support for JPEG and JPEG quality as well. Everything is controllable via settings page from the UI. The new settings have default values that make sense, which is output as PNG at lowest quality, which will still lead to good quality of the images at small file sizes.

heddn’s picture

Status: Needs review » Needs work
Issue tags: +PAreview: security

The project page should list entity as a dependency (and maybe libraries api). And there is what seems to be a security related issue. The rest of my feedback is more in the optional or question category. This project is great example the Drupal API and code standards and very close to RTBC.

scribble-brush-options.tpl:

foreach ($variables['brushes'] as $brush_id => $label):
  if ($first) {
    $checked = 'checked="checked"';
    $first = FALSE;
  }
  else {
    $checked = '';
  }

The control statement should use the ":" alternative syntax instead of curly braces in template files. Alternatively use https://api.drupal.org/api/drupal/developer%21topics%21forms_api_referen...

scribble-slideshow.tpl:
In the same vein, rather than an almost empty scribble-slideshow.tpl, consider #prefix/#suffix render array functionality:
https://drupal.org/node/930760

function scribble_requirements($phase) {
  $requirements = array();
  // Ensure translations don't break during installation.
  $t = get_t();

  if (in_array($phase, array('install', 'runtime')) && !file_exists(libraries_get_path('jqscribble') . '/jquery.jqscribble.js')) {
  

Is this a hidden dependency on libraries module? I'd think you would get an error if libraries wasn't installed on a missing function definition of libraries_get_path.

function scribble_install() {
  // This module renders the field values in it's own theme function, fields do
  // not to be displayed.

Nit: comment typo. fields do not (need) to be displayed.

function scribble_uninstall() {
  field_delete_field('scribble_title');
  field_delete_field('scribble_image');
  field_delete_field('scribble_brushes');
  field_delete_field('scribble_image_snapshots');
  field_delete_field('scribble_background_color');
...

  // @todo
  // field_delete_instance();

Instead of field_delete_field, if you only call delete instances then the last field base will automatically get deleted. However if someone uses an existing field on another content type, then this approach will break them. Not strictly important here because the field would probably break regardless, but something to consider.

js:

        $draw_canvas.data("jqScribble").save(function (imageData) {
          if(confirm(Drupal.t('You\'re about to save ur changes. Is that cool with you?')) && !$draw_canvas.data('jqScribble').blank) {
           

Miss spelling in the confirm.

function scribble_page_title($scribble, $title_part_key = NULL) {
  $items = field_get_items('scribble', $scribble, 'scribble_title');
  $return = $items[0]['value'];
  $title_parts = scribble_get_menu_title_parts();
  if ($title_part_key && array_key_exists($title_part_key, $title_parts)) {
    $return .= ' | ' . $title_parts[$title_part_key];
  }
  return $return;
}

Missing any sanitization on the title. That's a bit of a security issue.

function scribble_prepare_folders
Might want to make the destination for scribles more flexible so they can be stored in a private filesystem. Or maybe you don't. I think having them stored in private could get complicated and is more of an enhancement.

function scribble_remove_image_form($form, &$form_state, $scribble, $fid) {
  ...
  $question = t('Are you sure to remove image !image from scribble !scribble?', array(
    '!image' => $file->filename,
    '!scribble' => $scribble->label,
  ));

Typo in confirm message. Are you sure you (want) to remove.

s_leu’s picture

Status: Needs work » Needs review

@heddn

Thank you very much for your detailed review of the code.
I went through it and fixed the following things:

  1. Removed templates for brush options and slideshow and replaced them by normal theme functions
  2. Added dependency to the libraries API module. Actually i didn't add a dependency to it because the field slideshow module already is depending on it. But i didn't consider whether or not this module is enabled at the time hook_requirements is executed. So to make sure it is, i added the dependency.
  3. Added entity and libraries API as dependencies in the project description
  4. Fixed the mentioned typos in various files.
  5. Replaced calls to field_delete_field() by field_delete_instance() in hook_uninstall as suggested.
  6. Fixed the mentioned security issue in the title callback by using the fields safe_value instead of value

Regarding the mentioned option to make the output folder configurable and possibility to use private files directory. I basically agree, but it's something that i will implement once there is a need for it as well as an issue in the issue queue once the project is published and used.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Nothing is a blocker. However some minor feedback below. Consider using drush and coder. You can even set it up with a git pre-commit hook using drush coder-review --git.

.module:
127 | WARNING | A comma should follow the last multiline array item.
952 | ERROR | Missing parameter type at position 1
954 | ERROR | Missing parameter type at position 2

s_leu’s picture

Thanks for the hint heddn. I tried to use

drush coder-review scribble --minor

but somehow it didn't find the stuff your mentioned. I fixed it anyway now.
Also made a complete code inspection and fixed some further stuff according to that.

s_leu’s picture

Can this be finally released? It's on Reviewed & tested by the community since over 5 months. Please let me know if further changes are required in order to release it.

pushpinderchauhan’s picture

Getting review bonus would help speed up the process and make sure it gets on the review admins radar.

s_leu’s picture

Getting review bonus would help speed up the process and make sure it gets on the review admins radar.

What about those reviews?

https://www.drupal.org/node/2152083#comment-8251349
https://www.drupal.org/node/2152083#comment-8251445
https://www.drupal.org/node/2152083#comment-8251471

Am i required to do more reviewing in order to get my module published?

s_leu’s picture

Issue tags: +PAreview: review bonus
klausi’s picture

Issue tags: -PAreview: review bonus

Removing review bonus tag, you have not done all manual reviews, you just posted the output of an automated review tool. Make sure to read through the source code of the other projects, as requested on the review bonus page.

And please add the links to your reviews to the issue summary as requested on the review bonus page.

kscheirer’s picture

Assigned: Unassigned » klausi

Security question:

  1. In scribble_save_ajax() are there any security concerns about converting POST values to an image and eventually writing it to disk?

Non-blocking issues:

  • If you use the Libraries API, you don't have to require the sites/all/libraries path in scribble_requirements()
  • In your validate functions like scribble_settings_validate_jpeg_quality(), becareful using is_numeric, this will be TRUE for floats, octals, hex, &c. ctype_digit() may be better here.
  • Also if you set the form element to '#required' => TRUE then you don't need the empty checks in the validate functions
  • Do you need the empty ScribbleMetadataController class?

Assigning to klausi for the security question, otherwise this is ready to go from me!

klausi’s picture

Assigned: klausi » Unassigned
Status: Reviewed & tested by the community » Needs work

As far as I can see scribble_save_ajax() is no a security risk, since it just saves uploaded data to an image file. That is basically the same as uploading a file over a file field widget.

I'm more concerned about the scribble ID which also directly comes from $_POST and is never validated. What characters are allowed in a scribble ID? That should be checked before using it in a filename. I'm not sure how that could be exploited exactly, but you can come up with some ideas like '../../../../somewhere' and try to build an attack from that. Can you validate the scribble ID before doing the file processing?

s_leu’s picture

Status: Needs work » Reviewed & tested by the community

I'm more concerned about the scribble ID which also directly comes from $_POST and is never validated

Thanks a lot for the heads up on this one. I fixed that now, see the attached patch. I will also fix the additional points mentioned in #27. I'm assigning back to you kscheirer as you seem to be in charge to finally give me permission to release my project?

By the way i got some question. Somehow all commits are credited to my former username DrupOn, which i'm actually not using anymore. Also the ssh key i used to push commits to the scribble repository is on my user account (s_leu). Is there a possibility to move the commits to the s_leu account? If so how can i accomplish this?

s_leu’s picture

StatusFileSize
new1.83 KB
kscheirer’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for those updates! Normally we ask that you don't RTBC your own issues, but the changes were small and this application has been around too long already. I'm not sure how to move credit from one git account to another, maybe this will help? http://stackoverflow.com/questions/3042437/change-commit-author-at-one-s....

Thanks for your contribution, s_leu!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.