|
26 | 26 |
|
27 | 27 | E.update({
|
28 | 28 | "unknown-start-tag":
|
29 |
| - _(u"Unknown start tag <%(tagName)s'"), |
| 29 | + _(u"Unknown start tag <%(tagName)s>."), |
30 | 30 | "unknown-attribute":
|
31 |
| - _(u"Unknown '%(attributeName)s' attribute on <%(tagName)s>"), |
| 31 | + _(u"Unknown '%(attributeName)s' attribute on <%(tagName)s>."), |
32 | 32 | "missing-required-attribute":
|
33 |
| - _(u"Missing required '%(attributeName)s' attribute on <%(tagName)s>"), |
| 33 | + _(u"Missing required '%(attributeName)s' attribute on <%(tagName)s>."), |
34 | 34 | "unknown-input-type":
|
35 |
| - _(u"Unknown value for input type: '%(inputType)s'"), |
| 35 | + _(u"Illegal value for <input type> attribute: '%(inputType)s'."), |
36 | 36 | "attribute-not-allowed-on-this-input-type":
|
37 |
| - _(u"'%(attributeName)s' attribute is not allowed on <input type='%(inputType)s'>"), |
| 37 | + _(u"'%(attributeName)s' attribute is not allowed on <input type=%(inputType)s>."), |
| 38 | + "deprecated-attribute": |
| 39 | + _(u"'%(attributeName)s' attribute is deprecated on <%(tagName)s>."), |
38 | 40 | })
|
39 | 41 |
|
40 | 42 | globalAttributes = frozenset(('class', 'contenteditable', 'contextmenu', 'dir',
|
|
130 | 132 | 'tr': frozenset(()),
|
131 | 133 | 'td': frozenset(('colspan', 'rowspan')),
|
132 | 134 | 'th': frozenset(('colspan', 'rowspan', 'scope')),
|
133 |
| -# 'form': frozenset(('action', 'method', 'enctype', 'accept', 'name', 'onsubmit', |
134 |
| -# 'onreset', 'accept-charset', 'data', 'replace')), |
135 | 135 | # all possible <input> attributes are listed here but <input> is really handled separately
|
136 | 136 | 'input': frozenset(('accept', 'accesskey', 'action', 'alt', 'autocomplete', 'autofocus', 'checked', 'disabled', 'enctype', 'form', 'inputmode', 'list', 'maxlength', 'method', 'min', 'max', 'name', 'pattern', 'step', 'readonly', 'replace', 'required', 'size', 'src', 'tabindex', 'target', 'template', 'value')),
|
| 137 | +# 'form': frozenset(('action', 'method', 'enctype', 'accept', 'name', 'onsubmit', |
| 138 | +# 'onreset', 'accept-charset', 'data', 'replace')), |
137 | 139 | # 'button': frozenset(('name', 'value', 'type', 'disabled', 'form', 'autofocus')),
|
138 | 140 | # 'select': frozenset(('name', 'size', 'multiple', 'disabled', 'data', 'accesskey',
|
139 | 141 | # 'form', 'autofocus')),
|
|
160 | 162 | 'nest': frozenset(()),
|
161 | 163 | 'legend': frozenset(()),
|
162 | 164 | 'div': frozenset(()),
|
163 |
| - 'font': frozenset(('style',)), |
| 165 | + 'font': frozenset(('style',)) |
164 | 166 | }
|
165 | 167 |
|
166 | 168 | requiredAttributeMap = {
|
|
171 | 173 | 'object': frozenset(()), # XXX one of 'data' or 'type' is required
|
172 | 174 | 'param': frozenset(('name', 'value')),
|
173 | 175 | 'source': frozenset(('src',)),
|
174 |
| - 'map': frozenset(('id',)), |
| 176 | + 'map': frozenset(('id',)) |
175 | 177 | }
|
176 | 178 |
|
177 | 179 | inputTypeAllowedAttributeMap = {
|
|
198 | 200 | 'number': frozenset(('accesskey', 'autocomplete', 'autofocus', 'disabled', 'form', 'list', 'min', 'max', 'name', 'step', 'readonly', 'required', 'tabindex', 'value')),
|
199 | 201 | 'range': frozenset(('accesskey', 'autocomplete', 'autofocus', 'disabled', 'form', 'list', 'min', 'max', 'name', 'step', 'readonly', 'required', 'tabindex', 'value')),
|
200 | 202 | 'email': frozenset(('accesskey', 'autocomplete', 'autofocus', 'disabled', 'form', 'inputmode', 'list', 'maxlength', 'name', 'pattern', 'readonly', 'required', 'tabindex', 'value')),
|
201 |
| - 'url': frozenset(('accesskey', 'autocomplete', 'autofocus', 'disabled', 'form', 'inputmode', 'list', 'maxlength', 'name', 'pattern', 'readonly', 'required', 'tabindex', 'value')), |
| 203 | + 'url': frozenset(('accesskey', 'autocomplete', 'autofocus', 'disabled', 'form', 'inputmode', 'list', 'maxlength', 'name', 'pattern', 'readonly', 'required', 'tabindex', 'value')) |
| 204 | +} |
| 205 | + |
| 206 | +inputTypeDeprecatedAttributeMap = { |
| 207 | + 'text': frozenset(('size',)), |
| 208 | + 'password': frozenset(('size',)) |
202 | 209 | }
|
203 | 210 |
|
204 | 211 | class HTMLConformanceChecker(_base.Filter):
|
@@ -248,6 +255,11 @@ def validateStartTagInput(self, token):
|
248 | 255 | "data": "attribute-not-allowed-on-this-input-type",
|
249 | 256 | "datavars": {"attributeName": attrName,
|
250 | 257 | "inputType": inputType}}
|
| 258 | + if attrName in inputTypeDeprecatedAttributeMap.get(inputType, []): |
| 259 | + yield {"type": "ParseError", |
| 260 | + "data": "deprecated-attribute", |
| 261 | + "datavars": {"attributeName": attrName, |
| 262 | + "inputType": inputType}} |
251 | 263 |
|
252 | 264 | def checkUnknownStartTag(self, token):
|
253 | 265 | # check for recognized tag name
|
|
0 commit comments