mime_header.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9/* DEBUG: section 25 MiME Header Parsing */
10
11#include "squid.h"
12#include "debug/Stream.h"
13#include "mime_header.h"
14#include "sbuf/SBuf.h"
15
16size_t
17headersEnd(const char *mime, size_t l, bool &containsObsFold)
18{
19 size_t e = 0;
20 int state = 1;
21 containsObsFold = false;
22
23 while (e < l && state < 3) {
24 switch (state) {
25
26 case 0:
27
28 if ('\n' == mime[e])
29 state = 1;
30
31 break;
32
33 case 1:
34 if ('\r' == mime[e])
35 state = 2;
36 else if ('\n' == mime[e])
37 state = 3;
38 else if (' ' == mime[e] || '\t' == mime[e]) {
39 containsObsFold = true;
40 state = 0;
41 } else
42 state = 0;
43
44 break;
45
46 case 2:
47 if ('\n' == mime[e])
48 state = 3;
49 else
50 state = 0;
51
52 break;
53
54 default:
55 break;
56 }
57
58 ++e;
59 }
60
61 if (3 == state)
62 return e;
63
64 return 0;
65}
66
67size_t
68headersEnd(const SBuf &buf, bool &containsObsFold)
69{
70 return headersEnd(buf.rawContent(), buf.length(), containsObsFold);
71}
72
Definition: SBuf.h:94
const char * rawContent() const
Definition: SBuf.cc:509
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:415
size_t headersEnd(const char *mime, size_t l, bool &containsObsFold)
Definition: mime_header.cc:17

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors