Record Buckets - Batch Edit redirect - Regex replace that fails for us

Bug #1862694 reported by Josh Stompro
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
New
Undecided
Unassigned

Bug Description

EG 3.3.4

Our hostname contains a prefix of eg, so the code for batch editing records from a bucket fails for us, since it does a regex replace using /\/eg.*/ to create the new URL. So we cannot load the batch edit interface.

"https://egcatalog.larl.org/eg/staff/cat/catalog/batchEdit/bucket/11732"
gets turned into
"https://opac/extras/merge_template"

Code at
https://git.evergreen-ils.org/?p=Evergreen.git;a=blob;f=Open-ILS/web/js/ui/default/staff/cat/catalog/app.js;hb=851572686b9d3c827bca282449d66299cc929e2e#l2079

$scope.batchedit_url = $location.absUrl().replace(/\/eg.*/, '/opac/extras/merge_template');

Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I found one other instance that could cause problems, if anyone has a hostname starting with staff.

https://git.evergreen-ils.org/?p=Evergreen.git;a=blob;f=Open-ILS/web/js/ui/default/staff/cat/item/app.js;hb=HEAD#l1145

var url = $location.absUrl().replace(/\/staff.*/, '/actor/user/event_log');

That would match
https://staff.taco.org/eg/staff/opac

I think it both cases the regex just needs to include the trailing forward slash so it cannot match the beginning of the hostname.

Unless "$scope.batchedit_url = $location.absUrl().replace(/\/eg.*/, '/opac/extras/merge_template');" is supposed to match /eg2/ or /eg/ ?

Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Is there a reason that the new URL can't be created by something like this instead to avoid a regex and related issues?

$scope.batchedit_url = $location.protocol()+'://'+$location.host()+'/opac/extras/merge_template';

Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Here is a working branch that fixes the issue that is causing us trouble (all our evergreen servers use the prefix eg in the hostname, so I can replicate this in testing and production.

user/stompro/lp1862694_record_bucket_batch_edit_eg_prefix_hostname

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/stompro/lp1862694_record_bucket_batch_edit_eg_prefix_hostname

To test this bug, you need a system with a hostname that starts with "eg" to trigger the original issue.

1. Open up record buckets.
2. Pick a bucket that has some records.
3. select a few of them and choose batch edit.
4. the new batch edit tab should open and the iframe will give an error about not being able to load.

After the fix is applied, the iframe will load the batch edit interface.

Even without changing your servers hostname, you can test that the batch edit still works for you after the fix is applied.

I think there are a bunch of instances of the regex being set to match /\/staff.*/
https://git.evergreen-ils.org/?p=Evergreen.git&a=search&h=HEAD&st=grep&s=%2F%5C%2Fstaff.*%2F
but I want to keep this bug report specific to the one that is causing us issues to make it easier to test.

We are using this change in production now, I'll report back if there are any problems.

Josh

tags: added: pullrequest
Changed in evergreen:
milestone: none → 3.6.1
tags: added: cleanup
Changed in evergreen:
milestone: 3.6.1 → 3.6.2
Changed in evergreen:
milestone: 3.6.2 → 3.6.3
Changed in evergreen:
milestone: 3.6.3 → 3.6.4
Changed in evergreen:
milestone: 3.6.4 → 3.7.2
Changed in evergreen:
milestone: 3.7.2 → 3.7.3
Changed in evergreen:
milestone: 3.7.3 → none
no longer affects: evergreen/3.6
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

We have used this fix in production for almost 2 years now with no problem.
Josh

Revision history for this message
Jason Boyer (jboyer) wrote :

Marking duplicate of generic "We're regex-ing wrong" bug 1862834.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.