/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "net.h"
#include "str.h"
#include "strescape.h"
#include "http-url.h"
#include "http-parser.h"
/*
Character definitions:
tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
/ "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
/ DIGIT / ALPHA
; any VCHAR, except special
special = "(" / ")" / "<" / ">" / "@" / ","
/ ";" / ":" / "\" / DQUOTE / "/" / "["
/ "]" / "?" / "=" / "{" / "}"
qdtext = OWS / %x21 / %x23-5B / %x5D-7E / obs-text
qdtext-nf = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
ctext = OWS / %x21-27 / %x2A-5B / %x5D-7E / obs-text
obs-text = %x80-FF
OWS = *( SP / HTAB )
VCHAR = %x21-7E
't68char' = ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/"
'text' = ( HTAB / SP / VCHAR / obs-text )
Character bit mappings:
(1<<0) => ALPHA / DIGIT / "-" / "." / "_" / "~" / "+"
(1<<1) => "!" / "#" / "$" / "%" / "&" / "'" / "*" / "^" / "`" / "|"
(1<<2) => special
(1<<3) => %x21 / %x2A-5B / %x5D-7E
(1<<4) => %x23-29
(1<<5) => %x22-27
(1<<6) => HTAB / SP / obs-text
(1<<7) => "/"
*/
0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, // 00
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10
64, 10, 36, 50, 50, 50, 50, 50, 20, 20, 10, 9, 12, 9, 9, 140, // 20
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 12, 12, 12, 12, 12, // 30
12, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 40
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 4, 12, 10, 9, // 50
10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 60
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 10, 12, 9, 0, // 70
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 80
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 90
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // A0
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // B0
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // C0
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // D0
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // E0
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // F0
};
/*
* HTTP value parsing
*/
{
}
{
/* OWS = *( SP / HTAB ) */
return;
}
}
{
/* token = 1*tchar */
return 0;
return 1;
}
{
int ret;
return ret;
return 1;
}
const char **token_r)
{
Appendix B:
For compatibility with legacy list rules, recipients SHOULD accept
empty list elements. In other words, consumers would follow the list
productions:
#element => [ ( "," / element ) *( OWS "," [ OWS element ] ) ]
1#element => *( "," OWS ) element *( OWS "," [ OWS element ] )
*/
for (;;) {
break;
return 0;
}
return 1;
}
{
/* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
qdtext = HTAB / SP / "!" / %x23-5B ; '#'-'['
/ %x5D-7E ; ']'-'~'
/ obs-text
quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
obs-text = %x80-FF
*/
/* DQUOTE */
return 0;
/* *( qdtext / quoted-pair ) */
for (;;) {
const unsigned char *first;
/* *qdtext */
return -1;
/* DQUOTE */
break;
/* "\" */
return -1;
/* ERROR */
} else {
return -1;
}
}
return 1;
}
const char **word_r)
{
return 0;
}