From 1c732125bfd12fb3a25997f93cdf9e418666bddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 29 Dec 2014 17:21:16 +0100 Subject: Add cow_http_hd:parse_host/1, remove cow_http:parse_fullhost/1 From RFC7230 and RFC3986. The new function now validates that the characters are correct, but does not go as far as validate segment sizes or number of segments. Its main purpose is still to split host and port. --- include/cow_inline.hrl | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/cow_inline.hrl b/include/cow_inline.hrl index 649ff79..3abb018 100644 --- a/include/cow_inline.hrl +++ b/include/cow_inline.hrl @@ -32,6 +32,10 @@ C =:= $Z ). +%% IS_ALPHANUM(Character) + +-define(IS_ALPHANUM(C), ?IS_ALPHA(C) orelse ?IS_DIGIT(C)). + %% IS_CHAR(Character) -define(IS_CHAR(C), C > 0, C < 128). @@ -43,14 +47,19 @@ C =:= $5 orelse C =:= $6 orelse C =:= $7 orelse C =:= $8 orelse C =:= $9 ). -%% IS_ALPHANUM(Character) - --define(IS_ALPHANUM(C), ?IS_ALPHA(C) orelse ?IS_DIGIT(C)). - %% IS_ETAGC(Character) -define(IS_ETAGC(C), C =:= 16#21; C >= 16#23, C =/= 16#7f). +%% IS_HEX(Character) + +-define(IS_HEX(C), + ?IS_DIGIT(C) orelse + C =:= $a orelse C =:= $b orelse C =:= $c orelse + C =:= $d orelse C =:= $e orelse C =:= $f orelse + C =:= $A orelse C =:= $B orelse C =:= $C orelse + C =:= $D orelse C =:= $E orelse C =:= $F). + %% IS_TOKEN(Character) -define(IS_TOKEN(C), @@ -60,6 +69,19 @@ orelse C =:= $^ orelse C =:= $_ orelse C =:= $` orelse C =:= $| orelse C =:= $~ ). +%% IS_URI_UNRESERVED(Character) + +-define(IS_URI_UNRESERVED(C), + ?IS_ALPHA(C) orelse ?IS_DIGIT(C) orelse + C =:= $- orelse C =:= $. orelse C =:= $_ orelse C =:= $~). + +%% IS_URI_SUB_DELIMS(Character) + +-define(IS_URI_SUB_DELIMS(C), + C =:= $! orelse C =:= $$ orelse C =:= $& orelse C =:= $' orelse + C =:= $( orelse C =:= $) orelse C =:= $* orelse C =:= $+ orelse + C =:= $, orelse C =:= $; orelse C =:= $=). + %% IS_VCHAR(Character) -define(IS_VCHAR(C), C =:= $\t; C > 31, C < 127). -- cgit v1.2.3