aboutsummaryrefslogtreecommitdiff
path: root/iri.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-02-05 14:31:53 +0000
committerOmar Polo <op@omarpolo.com>2021-02-05 14:31:53 +0000
commit8404ec301fed4f0bb5a3d1e7b5a2e184a93cc4e5 (patch)
treee13c781fb785af232191412b46354a5b229e530b /iri.c
parent709f4c94471b5b910557420ab9bddb677c229100 (diff)
don't %-decode the query
Diffstat (limited to 'iri.c')
-rw-r--r--iri.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/iri.c b/iri.c
index efdeb11..8501d9a 100644
--- a/iri.c
+++ b/iri.c
@@ -46,12 +46,42 @@ sub_delimiters(int p)
}
static int
+valid_pct_enc_string(char *s)
+{
+ if (*s != '%')
+ return 1;
+
+ if (!isxdigit(s[1]) || !isxdigit(s[2]))
+ return 0;
+
+ if (s[1] == '0' && s[2] == '0')
+ return 0;
+
+ return 1;
+}
+
+static int
+valid_pct_encoded(struct parser *p)
+{
+ if (p->iri[0] != '%')
+ return 0;
+
+ if (!valid_pct_enc_string(p->iri)) {
+ p->err = "illegal percent-encoding";
+ return 0;
+ }
+
+ p->iri += 2;
+ return 1;
+}
+
+static int
parse_pct_encoded(struct parser *p)
{
if (p->iri[0] != '%')
return 0;
- if (!isxdigit(p->iri[1]) || !isxdigit(p->iri[2])) {
+ if (!valid_pct_enc_string(p->iri)) {
p->err = "illegal percent-encoding";
return 0;
}
@@ -259,7 +289,7 @@ parse_query(struct parser *p)
|| sub_delimiters(*p->iri)
|| *p->iri == '/'
|| *p->iri == '?'
- || parse_pct_encoded(p)
+ || valid_pct_encoded(p)
|| valid_multibyte_utf8(p))
p->iri++;