[Koha-bugs] [Bug 23680] New: Perl string '0' evaluated as javascript boolean triggers window.close() when should not

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Sep 26 11:49:15 CEST 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23680

            Bug ID: 23680
           Summary: Perl string '0' evaluated as javascript boolean
                    triggers window.close() when should not
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Staff Client
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: glasklas at gmail.com
        QA Contact: testopia at bugs.koha-community.org
                CC: gmcharlt at gmail.com

In cataloging_additem.inc the javascript variable "popup" is generated as:

var popup = '[% popup | html %]';

So popup will be either '0' or '1'. '0' is a truthy value in javascript, so
popup will always be evaluated as true making this condition:

if( popup && op != 'saveitem' ){
  window.close();
}

in cataloging_additem.js (incorrectly) true for every operation except
saveitem.

A windows can only be closed by javascript in certain conditions (don't know if
all browsers behave exactly the same), but for window.close() to actually close
the window it needs to be opened in new window/tab. So to reproduce this bug go
to a bibliographic record, expand the "New" menu, and open "New item" in new
tab. It should immediately close, which this patch should fix.

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list