# Content restrictions

A file's name says little about what is in it: anybody can call a program `report.pdf`. A content rule makes the server look at the first bytes of an uploaded file and check that they are what a file of that kind starts with. An upload that does not pass is refused.

The card **Content Restriction** is on the [Restrictions](Users-Restrictions.md) tab of a user in the User Manager. "No content rules." means that nothing is checked.

## A rule

**Add** makes a rule:

| Field | What it is |
|---|---|
| **Name** | a name for the rule, for yourself |
| **File extension** | the files the rule is for, as a pattern: `*.pdf`, `*.exe` |
| **Path** | the folder the rule is for. Leave it empty for all of the user's folders. |
| **Validation type** | how the bytes below are used: whether a file must have them to be let in, or is refused when it has them |
| **Offset entries** | the bytes to look for, each with its position, see below |

### Offset entries

Each entry names a place in the file and the byte that is expected there:

| Field | What it is |
|---|---|
| **Offset** | the position of the byte, counted from 0 at the start of the file |
| **Byte Value** | the value of the byte |

A PDF file starts with the four characters `%PDF`. A rule that lets only real PDF files in has four entries: offsets 0, 1, 2 and 3 with the values of those four characters.

## Two ways to use it

- **"Files named like this must really be this."** A rule for `*.pdf` that demands the PDF start. A program renamed to `.pdf` does not pass.
- **"Nothing that starts like this, whatever it is called."** A rule for `*` that refuses files that start with the two characters `MZ`, with which Windows programs begin.

## Things to know

- Only the bytes you name are looked at. A rule is a quick check against renamed files, not a virus scanner. To scan what comes in, hand uploads to a scanner with an [event](Users-Events.md) or a job.
- The check is made on upload, on every protocol.
- For rules by file name alone, such as "no `.exe` at all", use the file name filters of the server in [Restrictions](Prefs-Restrictions-Filename-Filters.md), or the [file filters](Users-Misc-File-Filters.md) of the user.
- Set the rules on `default` to have them hold for everybody.
