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

--- Comment #2 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 205887
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205887&action=edit
Bug 43540: Recognize core-shipped short urls as local in local_referer

Koha ships Apache rewrites/aliases for several "short" or friendly OPAC
and staff URLs (apache-shared-opac.conf, apache-shared-intranet.conf,
koha-httpd.conf):

  /bib/<biblionumber>        - single record, rewritten internally [PT]
  /isbn/<isbn>, /issn/<issn> - rewritten internally [PT] to /search?q=...
  /search                    - ScriptAlias'd straight to opac-search.pl /
                               catalogue/search.pl

None of these ever appear as /cgi-bin/koha/... in the browser's Referer
header: the [PT] rewrites happen internally (the browser keeps showing
the original short URL), and /search is aliased to a script outside
/cgi-bin/koha/ altogether.

Koha::Util::Navigation::local_referer(), used by opac-changelanguage.pl
and changelanguage.pl to redirect back to the referring page after a
language switch, only recognized a referer as local if it matched the
site's base URL AND contained the literal substring /cgi-bin/koha/.
Since none of the above contain that substring, the language switch
fell back to the site root, dropping the user on the homepage instead
of returning them to the record or search they were viewing.

This patch extends local_referer()'s recognized local-path pattern to
also accept /bib/<digits>, /isbn/<isbn>, /issn/<issn> and /search, in
both the base-URL branch and the no-base-URL fallback branch.

Test plan:
1. Enable mod_rewrite and confirm /bib/<biblionumber>, /isbn/<isbn> and
   /issn/<issn> all load the expected OPAC page.
2. On each of those pages, switch OPAC language via the language
   selector.
3. Before this patch: redirected to the OPAC homepage.
4. After this patch: redirected back to the same short URL.
5. prove t/Koha/Util/Navigation.t - all tests pass.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to