---
name: "Debbugs::CGI"
section: "3pm"
platform: "linux"
package: "libdebbugs-perl"
version: "2.6.4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Debbugs::CGI"
---

# Debbugs::CGI(3pm)

## NAME

Debbugs::CGI -- General routines for the cgi scripts

## SYNOPSIS

use Debbugs::CGI qw(:url :html);

## DESCRIPTION

This module is a replacement for parts of common.pl; subroutines in common.pl will be gradually phased out and replaced with equivalent (or better) functionality here.

## BUGS

None known.

### set\_url\_params

```
     set_url_params($uri);
```

Sets the url params which will be used to generate urls.

### munge\_url

```
     my $url = munge_url($url,%params_to_munge);
```

Munges a url, replacing parameters with `%params_to_munge` as appropriate.

### version\_url

```
     version_url(package => $package,found => $found,fixed => $fixed)
```

Creates a link to the version cgi script

- package -- source package whose graph to display

  - found -- arrayref of found versions

  - fixed -- arrayref of fixed versions

  - width -- optional width of graph

  - height -- optional height of graph

  - info -- display html info surrounding graph; defaults to 1 if width and height are not passed.

  - collapse -- whether to collapse the graph; defaults to 1 if width and height are passed.

  ### html\_escape

```
     html_escape($string)
```

Escapes html entities by calling HTML::Entities::encode\_entities;

### cgi\_parameters

```
     cgi_parameters
```

Returns all of the cgi\_parameters from a CGI script using CGI::Simple

## HTML

### htmlize\_packagelinks

```
     htmlize_packagelinks
```

Given a scalar containing a list of packages separated by something that "splitpackages" in Debbugs::CGI can separate, returns a formatted set of links to packages in html.

### package\_links

```
     join(', ', package_links(packages => \@packages))
```

Given a list of packages, return a list of html which links to the package

- package -- arrayref or scalar of package(s)

  - submitter -- arrayref or scalar of submitter(s)

  - src -- arrayref or scalar of source(s)

  - maintainer -- arrayref or scalar of maintainer(s)

  - links\_only -- return only links, not htmlized links, defaults to returning htmlized links.

  - class -- class of the a href, defaults to ''

  ### bug\_links

```
     join(', ', bug_links(bug => \@packages))
```

Given a list of bugs, return a list of html which links to the bugs

- bug -- arrayref or scalar of bug(s)

  - links\_only -- return only links, not htmlized links, defaults to returning htmlized links.

  - class -- class of the a href, defaults to ''

  ### maybelink

```
     maybelink($in);
     maybelink('http://foobarbaz,http://bleh',qr/[, ]+/);
     maybelink('http://foobarbaz,http://bleh',qr/[, ]+/,', ');
```

In the first form, links the link if it looks like a link. In the second form, first splits based on the regex, then reassembles the link, linking things that look like links. In the third form, rejoins the split links with commas and spaces.

### htmlize\_addresslinks

```
     htmlize_addresslinks($prefixfunc,$urlfunc,$addresses,$class);
```

Generate a comma-separated list of HTML links to each address given in `$addresses`, which should be a comma-separated list of RFC822 addresses. `$urlfunc` should be a reference to a function like mainturl or submitterurl which returns the URL for each individual address.

### bug\_linklist

```
     bug_linklist($separator,$class,@bugs)
```

Creates a set of links to `@bugs` separated by `$separator` with link class `$class`.

XXX Use Params::Validate; we want to be able to support query arguments here too; we should be able to combine bug\_links and this function into one.

## Forms

### form\_options\_and\_normal\_param

```
     my ($form_option,$param) = form_options_and_normal_param(\%param)
           if $param{form_options};
     my $form_option = form_options_and_normal_param(\%param)
           if $param{form_options};
```

Translates from special form\_options to a set of parameters which can be used to run the current page.

The idea behind this is to allow complex forms to relatively easily cause options that the existing cgi scripts understand to be set.

Currently there are two commands which are understood: combine, and concatenate.

*combine*

Combine works by entering key,value pairs into the parameters using the key field option input field, and the value field option input field.

For example, you would have

```
 <input type="hidden" name="_fo_combine_key_fo_searchkey_value_fo_searchvalue" value="1">
```

which would combine the \_fo\_searchkey and \_fo\_searchvalue input fields, so

```
 <input type="text" name="_fo_searchkey" value="foo">
 <input type="text" name="_fo_searchvalue" value="bar">
```

would yield foo=\>'bar' in `%param`.

*concatenate*

Concatenate concatenates values into a single entry in a parameter

For example, you would have

```
 <input type="hidden" name="_fo_concatentate_into_foo_with_:_fo_blah_fo_bleargh" value="1">
```

which would combine the \_fo\_searchkey and \_fo\_searchvalue input fields, so

```
 <input type="text" name="_fo_blah" value="bar">
 <input type="text" name="_fo_bleargh" value="baz">
```

would yield foo=\>'bar:baz' in `%param`.

### option\_form

```
     print option_form(template=>'pkgreport_options',
                       param   => \%param,
                       form_options => $form_options,
                      )
```

## misc

### maint\_decode

```
     maint_decode
```

Decodes the funky maintainer encoding.

Don't ask me what in the world it does.

## cache

### calculate\_etags

```
    calculate_etags(files => [qw(list of files)],additional_data => [qw(any additional data)]);
```

### etag\_does\_not\_match

```
     etag_does_not_match(cgi=>$q,files=>[qw(list of files)],
         additional_data=>[qw(any additional data)])
```

Checks to see if the CGI request contains an etag which matches the calculated etag.

If there wasn't an etag given, or the etag given doesn't match, return the etag.

If the etag does match, return 0.
