|
62 | 62 | _(u"Value must be an integer: '%(attributeName)s' attribute on <%tagName)s>."),
|
63 | 63 | "invalid-root-namespace":
|
64 | 64 | _(u"Root namespace must be 'http://www.w3.org/1999/xhtml', or omitted."),
|
| 65 | + "invalid-browsing-context": |
| 66 | + _(u"Value must be one of ('_self', '_parent', '_top'), or a name that does not start with '_': '%(attributeName)s' attribute on <%(tagName)s>."), |
65 | 67 | })
|
66 | 68 |
|
67 | 69 | globalAttributes = frozenset(('class', 'contenteditable', 'contextmenu', 'dir',
|
@@ -402,13 +404,28 @@ def validateAttributeValueId(self, token, tagName, attrName, attrValue):
|
402 | 404 | def validateAttributeValueTabindex(self, token, tagName, attrName, attrValue):
|
403 | 405 | for t in self.checkIntegerValue(token, tagName, attrName, attrValue) or []: yield t
|
404 | 406 |
|
| 407 | + def validateAttributeValueRef(self, token, tagName, attrName, attrValue): |
| 408 | + # XXX |
| 409 | + pass |
| 410 | + |
| 411 | + def validateAttributeValueTemplate(self, token, tagName, attrName, attrValue): |
| 412 | + # XXX |
| 413 | + pass |
| 414 | + |
405 | 415 | def validateAttributeValueHtmlXmlns(self, token, tagName, attrName, attrValue):
|
406 | 416 | if attrValue != "http://www.w3.org/1999/xhtml":
|
407 | 417 | yield {"type": "ParseError",
|
408 | 418 | "data": "invalid-root-namespace",
|
409 | 419 | "datavars": {"tagName": tagName,
|
410 | 420 | "attributeName": attrName}}
|
411 | 421 |
|
| 422 | + def validateAttributeValueBaseHref(self, token, tagName, attrName, attrValue): |
| 423 | + # XXX |
| 424 | + pass |
| 425 | + |
| 426 | + def validateAttributeValueBaseTarget(self, token, tagName, attrName, attrValue): |
| 427 | + for t in self.checkBrowsingContext(token, tagName, attrName, attrValue) or []: yield t |
| 428 | + |
412 | 429 | ##########################################################################
|
413 | 430 | # Attribute validation helpers
|
414 | 431 | ##########################################################################
|
@@ -525,6 +542,16 @@ def checkIntegerValue(self, token, tagName, attrName, attrValue):
|
525 | 542 | "datavars": {"tagName": tagName,
|
526 | 543 | "attributeName": attrName}}
|
527 | 544 |
|
| 545 | + def checkBrowsingContext(self, token, tagName, attrName, attrValue): |
| 546 | + if not attrValue: return |
| 547 | + if attrValue[0] != '_': return |
| 548 | + attrValue = attrValue.lower() |
| 549 | + if attrValue in frozenset(('_self', '_parent', '_top', '_blank')): return |
| 550 | + yield {"type": "ParseError", |
| 551 | + "data": "invalid-browsing-context", |
| 552 | + "datavars": {"tagName": tagName, |
| 553 | + "attributeName": attrName}} |
| 554 | + |
528 | 555 | ##########################################################################
|
529 | 556 | # Whole document validation (IDs, etc.)
|
530 | 557 | ##########################################################################
|
|
0 commit comments