From 0e3702891b7a9fe053df75fef34c78ba697dbc9e Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@koha-community.org> Date: Tue, 26 May 2015 13:05:51 +0200 Subject: [PATCH] [PASSED QA] Bug 14266: Trim the email address in the pl script The original concern of bug 14266 was to provide a compatibility for <IE9. But actually we don't need to trim the email address template side. It will even better to trim it in the perl script, so that the email will be trimed even if JS is disabled. Test plan: 1/ Share a list and does not provide any email address 2/ Submit => The form is not submited, no alert/message is displayed (same as before this patch). 3/ Share a list and provide an email address with spaces before and after 4/ Submit => You should receive the email Signed-off-by: Indranil Das Gupta (L2C2 Technologies) <indradg@gmail.com> Test output compliant with expected test plan outcome. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> --- .../bootstrap/en/modules/opac-shareshelf.tt | 17 +++++++++++++++-- opac/opac-shareshelf.pl | 6 ++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt index f40024f..19ee4b5 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt @@ -44,7 +44,7 @@ [% ELSIF op=='invite' %] <div id="invite"> - <form method="post" onsubmit="return $.trim($('#invite_address').val())!='';"> + <form id="share_list"> <fieldset class="rows"> <ol> <input type="hidden" name="op" value="conf_invite"/> @@ -89,4 +89,17 @@ </div> <!-- / .container-fluid --> </div> <!-- / .main --> [% INCLUDE 'opac-bottom.inc' %] -[% BLOCK jsinclude %][% END %] +[% BLOCK jsinclude %] +<script type="text/javascript"> +//<![CDATA[ + $(document).ready(function(){ + $("#share_list").on('submit', function(e) { + var address = $("#invite_address").val(); + if ( address.length == 0) { + e.preventDefault(); + } + }); + }); +//]]> +</script> +[% END %] diff --git a/opac/opac-shareshelf.pl b/opac/opac-shareshelf.pl index f29e170..3504ba1 100755 --- a/opac/opac-shareshelf.pl +++ b/opac/opac-shareshelf.pl @@ -60,6 +60,12 @@ sub _init { $param->{fail_addr} = []; $param->{errcode} = check_common_errors($param); + # trim email address + if ( $param->{addrlist} ) { + $param->{addrlist} =~ s|^\s+||; + $param->{addrlist} =~ s|\s+$||; + } + #get some list details my @temp; @temp = GetShelf( $param->{shelfnumber} ) if !$param->{errcode}; -- 1.7.2.5