Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 630592 - Bugzilla: use cheap javascript hack to display short bug URLs in the address bar
Summary: Bugzilla: use cheap javascript hack to display short bug URLs in the address bar
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Infrastructure
Classification: Unclassified
Component: Bugzilla (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Bugzilla Admins
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-10 15:21 UTC by Michał Górny
Modified: 2020-06-06 04:48 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-09-10 15:21:46 UTC
Right now, we support using mod_rewrite to redirect short bugzilla URLs (https://bugs.gentoo.org/NNNNNN) to long ones. We also kinda encourage people to use short URLs all over the place but we don't really publish them anywhere for easy use.

So right now, people have to either copy-paste the long URL from the address bar and cut it manually, or write it from scratch. I think it would be much better if we shown the short URL in the address bar, so people could copy it for direct use.


Originally, I was thinking about modifying Bugzilla completely to use short URLs whenever possible. However, that would either imply hard work on modifying URLs generated within Bugzilla, or using cheap mod_rewrite hacks that would result in a lot of unnecessary redirects.

What I'm thinking of right now is using the cheap JS trick [1] to update the address in place without reloading the page. In other words, Bugzilla will still be using and generating the long, old URLs and we'll be only updating the apparent URL. We might also want to change mod_rewrite to do silent rewriting of the short URLs (i.e. keeping the old address) instead of 302.

What do you think?

[1]:https://stackoverflow.com/a/39276694/165333
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-09-10 23:48:44 UTC
LGTM.

The one thing that probably needs changing in the source, is that it's still going to generate the long URLs in A HREF values. This is not as a easy as it seems, as places in the bugzilla source try and parse the URL to see if it contains 'show_bug.cgi':

Bugzilla/Bug.pm:        push @bug_ids, $text =~ /\b$urlbase_re\Qshow_bug.cgi?id=\E([0-9]+)(?:\#c[0-9]+)?/g;
Bugzilla/BugUrl/Bugzilla.pm:    return ($uri->path =~ /show_bug\.cgi$/) ? 1 : 0;
Bugzilla/Template.pm:    $text =~ s~\b(${urlbase_re}\Qshow_bug.cgi?id=\E([0-9]+)(\#c([0-9]+))?)\b
extensions/InlineHistory/web/inline-history.js:    var reBugId = /show_bug\.cgi\?id=(\d+)/;
extensions/SecureMail/Extension.pm:            my ($bug_id) = $href =~ /\Qshow_bug.cgi?id=\E(\d+)/;

Doing the JS hack for now is good, along with silent rewrite.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-09-11 15:06:18 UTC
This is now deployed on bugstest instance for testing.
Comment 3 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2017-09-11 21:50:52 UTC
This cheap hack produces URLs that are refused when pasted into a "See Also" when filing a new bug.

Should I file a seperate bug for that?
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-09-12 13:20:53 UTC
Fixing it on our end will be relatively simple. However, other Bugzillas will continue rejecting our short URLs. This is something we need to think about. I'll try reporting a bug upstream.