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
-
Run
vale doc/
-
Check for
✔ 0 errors, 0 warnings and 0 suggestions in 1307 files.
-
Run
vale curl.md
(file contents below) -
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
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Edited by Jonston Chan