Uploaded image for project: 'stripes-core'
  1. stripes-core
  2. STCOR-392

Browser back button not working: locationService.js generates invalid RexExp leading to call stack exhaustion

    XMLWordPrintable

Details

    • Core: F - Sprint 74
    • Prokopovych

    Description

      locationService.js contains a RegExp without proper escapes for backslashes which leads to callstack exhaustion. In the UI, this manifests as a broken back button.

      export function isQueryResourceModule(module, location) {
        if (!module) return false;
      
        const path = location.pathname;
        const re = new RegExp(`^${module.route}|^/settings${module.route}`, 'i');
      
        return module.queryResource && path.match(re);
      }
      

      Running locally, this leads to an error message in the console:

      Uncaught SyntaxError: Invalid regular expression: /^/users|^/settings/users/: Stack overflow
      

      which in production appears as

      _baseGetAllKeys.js:17 Uncaught RangeError: Maximum call stack size exceeded
          at e.exports (_baseGetAllKeys.js:17)
          at e.exports (_getAllKeys.js:13)
          at e.exports (_equalObjects.js:29)
          at e.exports (_baseIsEqualDeep.js:80)
          at e (_baseIsEqual.js:25)
          at e.exports (isEqual.js:32)
          at g (locationService.js:58)
          at MainNav.js:87
          at Object.M [as dispatch] (createStore.js:172)
          at e (<anonymous>:1:40553)
      

      Steps to reproduce:

      1. In tip of master (folio-testing or snapshot) or 3.2 (https://folio-daisy.aws.indexdata.com) but NOT in 3.1 (https://bugfestq31.folio.ebsco.com)
      2. Check an item out to a user
      3. From the checkout page, use the ••• menu then “Loan policy”, Loan details or Item details
      4. Click browser back button to return to Check out
      5. At this point the back button should cease to function and there is an error in the JS console.
      6. From checkout, click the number of open loans in the Borrower section to take you to the Loans page for that user
      7. use the ••• menu then Loan details or Item details
      8. Click browser back button to return to Loans

      Expected Browser back should return you to last visited page

      Actual As of 3.2 release, browser back sometimes doesn't work and there is an error in the JS console.

      Additional info While the known user impact isn't severe, Zak sees this as an important bug to fix as we aren't sure what other unknown implications there may be

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                zburke Zak_Burke
                zburke Zak_Burke
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases