Description
A small module that lets a user set the text for the form field required marker as well as the text of the title attribute of the marker.
The module adds one permission 'Administer Custom Required Marker' that is used to access the model's setting form.
The module adds a settings form for setting the custom marker and custom marker title attribute.
For static fields the module implements theme_form_required_marker(). For dynamic fields the module adds JavaScripts to override the default "state:required" bound function in states.js.
Project Link
https://www.drupal.org/sandbox/baglerit/2667946
Git Clone Command
git clone --branch 7.x-1.x https://git.drupal.org/sandbox/BaglerIT/2667946.git
Manual reviews of other projects
- E-MAILiT Share Buttons - https://www.drupal.org/node/2667164#comment-10852692
- Onepass - https://www.drupal.org/node/2667046#comment-10852690
- Select registration roles - https://www.drupal.org/node/2644054#comment-10854054
Somewhat related core issues
Thank you to mgifford for pulling these together.
Comments
Comment #2
dave bagler commentedComment #3
PA robot commentedWe 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.
Comment #4
mgiffordI read through the code and it looks fine. I haven't run it through coder or actually enabled it yet, but plan to do so.
Always a bit of a challenge with names as long as "custom_required_marker" & the 80 character lines. Not a big deal though.
Thanks for contributing this Dave. I know that there are folks who worry about this as an accessibility issue and will want to enable it for their site. I don't see it as a barrier (having discussed this in D7 & D8 Core) but it certainly makes it more explicit.
Somewhat related Core issues.
#1162802: Asterisk * used for required or changed marker should be in abbr not span
#2121775: Make the markup associated with the required star on field items silent
#72197: Forms should show explanation of required (*) fields
Comment #5
mgiffordRan the module. Behaved as expected. Coder gave it a great review too. This looks good to go for me.
Comment #6
dave bagler commentedComment #7
dave bagler commentedComment #8
dave bagler commentedComment #9
dave bagler commentedComment #10
dave bagler commentedComment #11
gotosolr commentedPosting the review below , needs one security fix
Automated Review :
Coder found no warnings, issues with the project.
Manual Review:
Individual user account
alert('XSS');Yes, Follows
No duplication
Yes,Follows
Master Branch
Yes: Follows
Licensing
Yes: Follows.
3rd party assets/code :
Yes, follows
Security Code:
No.
1.(*) The configuration form input fields need to be sanitized , If we enter
into the input, then it will create a javascript alert .This vulnerability is mitigated by the fact that an attacker must have permissions to administer the markers, but this should still be fixed.
2. Change the title and description of the second field (Custom Required Marker Marker to a more helpful one) to make it more clear , maybe Custom Required Marker Text ? Not a blocker, just a recommendation as it got me a little confused until I saw what it did.
After the security fix , it’s good to go
Comment #12
gotosolr commentedThe comment stripped the script tags around the alert, posting it below
<script>alert('XSS');</script>Comment #13
gotosolr commentedComment #14
dave bagler commentedThanks for the review gotosolr!
I guess I just didn't think about XSS since it's an admin module, so great catch on that one!
I've pushed a new commit to the sandbox that filters the marker text and marker title through
filter_xss_admin()and fixes the vulnerability.Also, based on your suggestion I've changed marker marker to marker text and I think you're right it's more clear.
Thanks again.
Comment #15
dave bagler commentedComment #16
dave bagler commentedComment #17
klausiComment #18
klausiOh and since there was an XSS vulnerability I'm adding the security tag. And please don't remove the security tag, we keep that for statistics and to show examples of security problems.
Comment #19
dave bagler commentedThanks for the feedback.
I've:
Also I'll leave the tags as they are. With those changes is the module good to go?
Comment #20
minoroffense commenteddrupal_add_js in the form alter should be replaced with #attached on the $form variable. Make sure everything works as expected. I let Dave know already.
Comment #21
dave bagler commentedThanks, I've updated the module to use #attached, re-tested to make sure it still works, and re-ran the coding standards automated review to make sure it still passes.
Comment #22
minoroffense commentedLooks good to me.
Comment #23
namit.garg commentedHi
The modules works fine just 2 issues that i noted
1> When we enter any text inside < > the text is not displayed as it is stripped
For eg if i enter in Textfield nothing is dipalyed
2>Instead of stripping for XSS which will change text it would be better if a form validation can be added to throw error when unwanted
character are entered in Textfields
Comment #24
josebc commentedI noticed you are are using "if (function_exists('i18n_variable_set'))" to handle variable translation which is not very conventional, there is a better way to implement this
please check https://www.drupal.org/node/1113374
Thank you for contributing
Comment #25
dave bagler commentednamit.garg, thanks for the review. I think at this time it would be best to just leave the filter_xss_admin() calls.
josebc, thanks for the review. I've updated the module to include the call to hook_variable_info(), and simplified the get/set variable code as well as the variable delete code in the install file.
Comment #26
dave bagler commentedSo the module has been reviewed by 6 people. The updates from 5 of them have been applied. I've responded to the other individual that I'd like to keep the XSS check in the code. At this point can this module be approved?
Comment #27
mgiffordAgreed that it's had a pretty through review at this stage.
Comment #28
dave bagler commentedComment #29
kattekrab commentedComment #30
mpdonadioAdding to my queue.
To address some specific comments in this issue:
#14, you never know who will have admin privileges on a site (think sites with multiple admins). It is even more important to protect admin pages from accidental input, as you may compromise a site via an admin user.
#23, the Drupal way is to store data exactly as entered and sanitize on output: https://www.drupal.org/node/28984
#24, that is something very minor and not a reason to push an application back to NW. The current main reasons are: security issues, licensing issues, and third-party code issues.
Comment #31
mpdonadioAutomated Review
Review of the 7.x-1.x branch (commit e3fb9a7):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
Security issues found by @klausi are addressed by using filter_xss_admin() in a preprocess for the theme function. Ok with me.
Also thought about this a bit, and do think filter_xss_admin() admin here is appropriate to allow an admin to build HTML for this for a11y reasons, instead of a plain text message.
You should add a hook_help() at some point.
custom_required_marker_settings_form() has a @see to a non-existant function.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
Two admins have looked at this; I feel comfortable here with promotion now.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #32
mpdonadioThanks for your contribution, Dave Bagler!
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.
Comment #33
dave bagler commentedThank you so much mpdonadio!
And thanks for the suggestions. I'll make those updates and then make it a full project.