33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
#define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */
#endif
/*
** These are the only markup attributes allowed.
*/
#define ATTR_ALIGN 1
#define ATTR_ALT 2
#define ATTR_BGCOLOR 3
#define ATTR_BORDER 4
#define ATTR_CELLPADDING 5
#define ATTR_CELLSPACING 6
#define ATTR_CLASS 7
#define ATTR_CLEAR 8
#define ATTR_COLOR 9
#define ATTR_COLSPAN 10
#define ATTR_COMPACT 11
#define ATTR_FACE 12
#define ATTR_HEIGHT 13
#define ATTR_HREF 14
#define ATTR_HSPACE 15
#define ATTR_ID 16
#define ATTR_LINKS 17
#define ATTR_NAME 18
#define ATTR_ROWSPAN 19
#define ATTR_SIZE 20
#define ATTR_SRC 21
#define ATTR_START 22
#define ATTR_STYLE 23
#define ATTR_TARGET 24
#define ATTR_TYPE 25
#define ATTR_VALIGN 26
#define ATTR_VALUE 27
#define ATTR_VSPACE 28
#define ATTR_WIDTH 29
#define AMSK_ALIGN 0x00000001
#define AMSK_ALT 0x00000002
#define AMSK_BGCOLOR 0x00000004
#define AMSK_BORDER 0x00000008
#define AMSK_CELLPADDING 0x00000010
#define AMSK_CELLSPACING 0x00000020
#define AMSK_CLASS 0x00000040
#define AMSK_CLEAR 0x00000080
#define AMSK_COLOR 0x00000100
#define AMSK_COLSPAN 0x00000200
#define AMSK_COMPACT 0x00000400
#define AMSK_FACE 0x00000800
#define AMSK_HEIGHT 0x00001000
#define AMSK_HREF 0x00002000
#define AMSK_HSPACE 0x00004000
#define AMSK_ID 0x00008000
#define AMSK_LINKS 0x00010000
#define AMSK_NAME 0x00020000
#define AMSK_ROWSPAN 0x00040000
#define AMSK_SIZE 0x00080000
#define AMSK_SRC 0x00100000
#define AMSK_START 0x00200000
#define AMSK_STYLE 0x00400000
#define AMSK_TARGET 0x00800000
#define AMSK_TYPE 0x01000000
#define AMSK_VALIGN 0x02000000
#define AMSK_VALUE 0x04000000
#define AMSK_VSPACE 0x08000000
#define AMSK_WIDTH 0x10000000
static const struct AllowedAttribute {
const char *zName;
unsigned int iMask;
} aAttribute[] = {
{ 0, 0 },
{ "align", AMSK_ALIGN, },
{ "alt", AMSK_ALT, },
{ "bgcolor", AMSK_BGCOLOR, },
{ "border", AMSK_BORDER, },
{ "cellpadding", AMSK_CELLPADDING, },
{ "cellspacing", AMSK_CELLSPACING, },
{ "class", AMSK_CLASS, },
{ "clear", AMSK_CLEAR, },
{ "color", AMSK_COLOR, },
{ "colspan", AMSK_COLSPAN, },
{ "compact", AMSK_COMPACT, },
{ "face", AMSK_FACE, },
{ "height", AMSK_HEIGHT, },
{ "href", AMSK_HREF, },
{ "hspace", AMSK_HSPACE, },
{ "id", AMSK_ID, },
{ "links", AMSK_LINKS, },
{ "name", AMSK_NAME, },
{ "rowspan", AMSK_ROWSPAN, },
{ "size", AMSK_SIZE, },
{ "src", AMSK_SRC, },
{ "start", AMSK_START, },
{ "style", AMSK_STYLE, },
{ "target", AMSK_TARGET, },
{ "type", AMSK_TYPE, },
{ "valign", AMSK_VALIGN, },
{ "value", AMSK_VALUE, },
{ "vspace", AMSK_VSPACE, },
{ "width", AMSK_WIDTH, },
};
/*
** Use binary search to locate a tag in the aAttribute[] table.
*/
static int findAttr(const char *z){
int i, c, first, last;
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#define WIKI_LINKSONLY 0x020 /* No markup. Only decorate links */
#endif
/*
** These are the only markup attributes allowed.
*/
enum allowed_attr_t {
ATTR_ALIGN = 1,
ATTR_ALT,
ATTR_BGCOLOR,
ATTR_BORDER,
ATTR_CELLPADDING,
ATTR_CELLSPACING,
ATTR_CLASS,
ATTR_CLEAR,
ATTR_COLOR,
ATTR_COLSPAN,
ATTR_COMPACT,
ATTR_FACE,
ATTR_HEIGHT,
ATTR_HREF,
ATTR_HSPACE,
ATTR_ID,
ATTR_LINKS,
ATTR_NAME,
ATTR_ROWSPAN,
ATTR_SIZE,
ATTR_SRC,
ATTR_START,
ATTR_STYLE,
ATTR_TARGET,
ATTR_TYPE,
ATTR_VALIGN,
ATTR_VALUE,
ATTR_VSPACE,
ATTR_WIDTH
};
enum amsk_t {
AMSK_ALIGN = 0x00000001,
AMSK_ALT = 0x00000002,
AMSK_BGCOLOR = 0x00000004,
AMSK_BORDER = 0x00000008,
AMSK_CELLPADDING = 0x00000010,
AMSK_CELLSPACING = 0x00000020,
AMSK_CLASS = 0x00000040,
AMSK_CLEAR = 0x00000080,
AMSK_COLOR = 0x00000100,
AMSK_COLSPAN = 0x00000200,
AMSK_COMPACT = 0x00000400,
/* re-use = 0x00000800, */
AMSK_FACE = 0x00001000,
AMSK_HEIGHT = 0x00002000,
AMSK_HREF = 0x00004000,
AMSK_HSPACE = 0x00008000,
AMSK_ID = 0x00010000,
AMSK_LINKS = 0x00020000,
AMSK_NAME = 0x00040000,
AMSK_ROWSPAN = 0x00080000,
AMSK_SIZE = 0x00100000,
AMSK_SRC = 0x00200000,
AMSK_START = 0x00400000,
AMSK_STYLE = 0x00800000,
AMSK_TARGET = 0x01000000,
AMSK_TYPE = 0x02000000,
AMSK_VALIGN = 0x04000000,
AMSK_VALUE = 0x08000000,
AMSK_VSPACE = 0x10000000,
AMSK_WIDTH = 0x20000000
};
static const struct AllowedAttribute {
const char *zName;
unsigned int iMask;
} aAttribute[] = {
/* These indexes MUST line up with their
corresponding allowed_attr_t enum values.
*/
{ 0, 0 },
{ "align", AMSK_ALIGN },
{ "alt", AMSK_ALT },
{ "bgcolor", AMSK_BGCOLOR },
{ "border", AMSK_BORDER },
{ "cellpadding", AMSK_CELLPADDING },
{ "cellspacing", AMSK_CELLSPACING },
{ "class", AMSK_CLASS },
{ "clear", AMSK_CLEAR },
{ "color", AMSK_COLOR },
{ "colspan", AMSK_COLSPAN },
{ "compact", AMSK_COMPACT },
{ "face", AMSK_FACE },
{ "height", AMSK_HEIGHT },
{ "href", AMSK_HREF },
{ "hspace", AMSK_HSPACE },
{ "id", AMSK_ID },
{ "links", AMSK_LINKS },
{ "name", AMSK_NAME },
{ "rowspan", AMSK_ROWSPAN },
{ "size", AMSK_SIZE },
{ "src", AMSK_SRC },
{ "start", AMSK_START },
{ "style", AMSK_STYLE },
{ "target", AMSK_TARGET },
{ "type", AMSK_TYPE },
{ "valign", AMSK_VALIGN },
{ "value", AMSK_VALUE },
{ "vspace", AMSK_VSPACE },
{ "width", AMSK_WIDTH },
};
/*
** Use binary search to locate a tag in the aAttribute[] table.
*/
static int findAttr(const char *z){
int i, c, first, last;
|