Skip to content

Quote URLs in cURL command

What does this MR do?

This MR:

  • adds a new regular expression to detect unquoted URLs in cURL commands
  • quotes the URLs that have been found by the updated Vale rule

The prior regular expression is kept to detect commands with quoted options before URL (for example, curl -F "key=value" https://gitlab.example.com/)

Related to #276200 (closed)

How to setup and validate locally

  1. Run vale doc/

  2. Check for ✔ 0 errors, 0 warnings and 0 suggestions in 1307 files.

  3. Run vale curl.md (file contents below)

  4. Check for ✔ 11 errors, 0 warnings and 0 suggestions in 1 files. (errors expected)

curl.md:

# Examples

## Examples that should raise an error

### Examples that do raise an error for current Vale rule

- `curl ftp://ftp.example.com`
- `curl http://http.example.com`
- `curl https://https.example.com`
- `curl 'https://single-quotes.example.com'`
- `curl https://fragment.example.com#anchor`
- `curl --url https://longhand-flag.example.com`
- `curl -O https://shorthand-flag.example.com`
- `curl -o page https://shorthand-option.example.com`

```
curl \
    https://plain-text-fenced-code-block.example.com/
```

```shell
curl \
    https://fenced-code-block.example.com/
```

### Examples that do not raise an error for current Vale rule

```shell
curl \
    -F "key=value" \
    https://fenced-code-block-with-curl-option.example.com/
```

```shell
curl \
    -F "key=value" \
    --url https://fenced-code-block-as-curl-option.example.com/
```

```
protocol='http://'
subdomain='variables.'
domain='example.com'

curl $protocol$subdomain$domain
curl ${protocol}${subdomain}${domain}
```



## Examples that should not raise an error

### Examples from unquoted URL section

- `curl "ftp://ftp.example.com"`
- `curl "http://http.example.com"`
- `curl "https://https.example.com"`
- `curl "https://fragment.example.com#anchor"`
- `curl --url "https://longhand-flag.example.com"`
- `curl -O "https://shorthand-flag.example.com"`
- `curl -o page "https://shorthand-option.example.com"`

```
curl \
    "https://plain-text-fenced-code-block.example.com/"
```

```shell
curl \
    "https://fenced-code-block.example.com/"
```

### Other examples


- `curl "https://query-string.example.com?url=http://example.com"`
- `curl "https://query-string.example.com?url=http://example.com&dev=true"`


```shell
curl \
    "https://fenced-code-block.example.com/"

# Workaround for https://comment.example.com/
echo "diable-check=true" > ~/.conf
```

```shell
curl \
    --data "url=https://example.com"
    "https://fenced-code-block.example.com/"
```

```shell
curl \
    --form 'url=http://example.com' \
    "https://example.com/"
```

```shell
curl \
    --header "PRIVATE-TOKEN: <your_access_token>" \
    --form 'url=http://example.com' \
    "https://gitlab.example.com/api/v4/projects/5/issues/93/metric_images"
```

Does this MR meet the acceptance criteria?

Conformity

Edited by Jonston Chan

Merge request reports

Loading