Fix uri format to follow RFC 3986
It seems that the current implementation is based on [RFC 2396 - 2.3. Unreserved Characters](https://tools.ietf.org/html/rfc2396#section-2.3). However, this RFC is obsoleted by [RFC 3986](https://tools.ietf.org/html/rfc3986). At [RFC 3986 - 2.3. Unreserved Characters](https://tools.ietf.org/html/rfc3986#section-2.3), the unreserved characters are defined as follows.

    unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

Thus we should update the implementation to follow the RFC 3986.

```sh
 % echo "-_.~\!'()" | jq -R @uri
"-_.~!'()"
 % echo "-_.~\!'()" | ./jq  -R @uri
"-_.~%21%27%28%29"
```

Resolves  #1506.
@uri documentation in manual:
```Applies percent-encoding, by mapping all reserved URI characters to a %XX sequence.```

However, it does not percent-encode certain reserved characters like `! ( ) *`.

```
echo '"!()*#$&+,/:;=?@[]"' | jq -r '@uri' 
!()*%23%24%26%2B%2C%2F%3A%3B%3D%3F%40%5B%5D
```


@uri is not percent-encoding all reserved characters
diff --git a/src/builtin.c b/src/builtin.c
index 9b2d9a23fc..79e96367fc 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -642,7 +642,7 @@ static jv f_format(jq_state *jq, jv input, jv fmt) {
     input = f_tostring(jq, input);
 
     int unreserved[128] = {0};
-    const char* p = CHARS_ALPHANUM "-_.!~*'()";
+    const char* p = CHARS_ALPHANUM "-_.~";
     while (*p) unreserved[(int)*p++] = 1;
 
     jv line = jv_string("");

diff --git a/tests/jq.test b/tests/jq.test
index ca8e27059f..b8364f2a77 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -61,17 +61,17 @@ null
 null
 "interpolation"
 
-@text,@json,([1,.] | (@csv, @tsv)),@html,@uri,@sh,@base64,(@base64 | @base64d)
-"<>&'\"\t"
-"<>&'\"\t"
-"\"<>&'\\\"\\t\""
-"1,\"<>&'\"\"\t\""
-"1\t<>&'\"\\t"
-"&lt;&gt;&amp;&apos;&quot;\t"
-"%3C%3E%26'%22%09"
-"'<>&'\\''\"\t'"
-"PD4mJyIJ"
-"<>&'\"\t"
+@text,@json,([1,.]|@csv,@tsv),@html,@uri,@sh,(@base64|.,@base64d)
+"!()<>&'\"\t"
+"!()<>&'\"\t"
+"\"!()<>&'\\\"\\t\""
+"1,\"!()<>&'\"\"\t\""
+"1\t!()<>&'\"\\t"
+"!()&lt;&gt;&amp;&apos;&quot;\t"
+"%21%28%29%3C%3E%26%27%22%09"
+"'!()<>&'\\''\"\t'"
+"ISgpPD4mJyIJ"
+"!()<>&'\"\t"
 
 # regression test for #436
 @base64

{"tests/jqtest": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"test_options": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "regset": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "callback_each_match": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/utf8test": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "names": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_utf8": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "simple": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/base64test": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "echo": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/mantest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testc": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_syntax": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_back": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "bug_fix": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "scan": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/onigtest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/shtest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "encode": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "callout": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "listcap": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "tests/optionaltest": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "user_property": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test_regset": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "testcu": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "count": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "syntax": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "sql": {"run": "PASS", "test": "PASS", "fix": "PASS"}}
{"tests/jqtest": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"passed_count": 28, "failed_count": 0, "skipped_count": 0, "passed_tests": ["regset", "callback_each_match", "names", "test_utf8", "testc", "test_syntax", "sql", "bug_fix", "scan", "tests/onigtest", "encode", "listcap", "tests/optionaltest", "test_regset", "testcu", "count", "syntax", "test_options", "tests/utf8test", "simple", "tests/base64test", "tests/mantest", "test_back", "tests/jqtest", "tests/shtest", "callout", "user_property", "echo"], "failed_tests": [], "skipped_tests": []}
{"passed_count": 27, "failed_count": 1, "skipped_count": 0, "passed_tests": ["regset", "callback_each_match", "names", "test_utf8", "testc", "test_syntax", "sql", "bug_fix", "scan", "tests/onigtest", "encode", "listcap", "tests/optionaltest", "test_regset", "testcu", "count", "syntax", "test_options", "tests/utf8test", "simple", "tests/base64test", "tests/mantest", "test_back", "tests/shtest", "callout", "user_property", "echo"], "failed_tests": ["tests/jqtest"], "skipped_tests": []}
{"passed_count": 28, "failed_count": 0, "skipped_count": 0, "passed_tests": ["regset", "callback_each_match", "names", "test_utf8", "testc", "test_syntax", "sql", "bug_fix", "scan", "tests/onigtest", "encode", "listcap", "tests/optionaltest", "test_regset", "testcu", "count", "syntax", "test_options", "tests/utf8test", "simple", "tests/base64test", "tests/mantest", "test_back", "tests/jqtest", "tests/shtest", "callout", "user_property", "echo"], "failed_tests": [], "skipped_tests": []}