Lint: use Python urlparse to verify esid fragment correctness

This commit is contained in:
Rick Waldron 2018-06-19 15:57:04 -04:00
parent 90c667afd1
commit ae3493a409
2 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,5 @@
from ..check import Check
from urlparse import urlparse
import re
class CheckEsid(Check):
@ -8,7 +9,6 @@ class CheckEsid(Check):
def __init__(self):
#self.es5idRegex = re.compile(r"^S?(B|\d+)(\.\d+)+(-(\d+|[a-z]|i+))*(_A\d(\.\d+)?(_T\d(\.\d+)?)?)?$")
self.es6idRegex = re.compile(r"^(S?(B|\d+)(\.\d+)+(((_A\d\.\d)?_T?\d)|[ _]S\d+(\.[a-z])*)?(, |$))+")
self.esidRegex = re.compile(r"^(pending|(prod|sec|sup)-[-_A-Za-z0-9.%@]+)$")
def run(self, name, meta, source):
if not meta:
@ -30,7 +30,7 @@ class CheckEsid(Check):
if 'esid' in meta:
esid = str(meta['esid'])
if self.esidRegex.match(esid) == None:
parsed = urlparse('#%s' % esid)
if parsed.fragment != esid:
return 'The `esid` tag has the wrong format: %s' % esid

View File

@ -0,0 +1,9 @@
^ expected errors | v input
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: any!thing$goes&-?
description: Minimal test
---*/
function f() {}