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>
Signed-off-by: Mason James <mtj@kohaaloha.com>
This commit is contained in:
Jonathan Druart 2015-05-26 13:05:51 +02:00 committed by Mason James
parent 69a74bb880
commit 8a9184c4bc
2 changed files with 21 additions and 2 deletions

View File

@ -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 %]

View File

@ -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};