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

Bug #1862694 reported by Josh Stompro on 2020-02-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
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

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

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

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
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers