Skip to content

Commit

Permalink
Updates for processing inline html attributes without <base>
Browse files Browse the repository at this point in the history
Disclosure system update
  • Loading branch information
hefischer committed Dec 18, 2018
1 parent 4b7e74d commit 1f3535a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions arelle/DisclosureSystem.py
Expand Up @@ -61,6 +61,7 @@ def clear(self):
setattr(self, typeTestVariable, False)
self.pluginTypes.add(typeName)
self.validateFileText = False
self.allowedExternalHrefPattern = None
self.schemaValidateSchema = None
self.blockDisallowedReferences = False
self.maxSubmissionSubdirectoryEntryNesting = 0
Expand Down Expand Up @@ -172,6 +173,8 @@ def select(self, name):
for typeName, typeTestVariable in pluginXbrlMethod(self):
setattr(self, typeTestVariable, self.validationType == typeName)
self.validateFileText = dsElt.get("validateFileText") == "true"
if dsElt.get("allowedExternalHrefPattern"):
self.allowedExternalHrefPattern = re.compile(dsElt.get("allowedExternalHrefPattern"))
self.blockDisallowedReferences = dsElt.get("blockDisallowedReferences") == "true"
try:
self.maxSubmissionSubdirectoryEntryNesting = int(dsElt.get("maxSubmissionSubdirectoryEntryNesting"))
Expand Down
4 changes: 3 additions & 1 deletion arelle/ModelDocument.py
Expand Up @@ -1211,8 +1211,10 @@ def inlineXbrlDiscover(self, htmlElement):
if _ns in XbrlConst.ixbrlAll:
ixNS = _ns
break
# required by 12.4.1 of [HTML] bullet 3
# use of document base is commented out because it discloses/uses absolute server directory and defeats URI redirection
if htmlBase is None:
htmlBase = os.path.dirname(self.uri) + "/"
htmlBase = "" # os.path.dirname(self.uri) + "/"
if conflictingNSelts:
self.modelXbrl.error("ix:multipleIxNamespaces",
_("Multiple ix namespaces were found"),
Expand Down
2 changes: 2 additions & 0 deletions arelle/ValidateXbrlDTS.py
Expand Up @@ -372,6 +372,7 @@ def linkbaseTopElts():
if l > 255:
val.modelXbrl.error("EFM.6.07.30",
_("Schema targetNamespace length (%(length)s) is over 255 bytes long in utf-8 %(targetNamespace)s"),
edgarCode="du-0730-Uri-Length-Limit",
modelObject=elt, length=l, targetNamespace=targetNamespace, value=targetNamespace)
if val.validateSBRNL:
if elt.get("targetNamespace") is None:
Expand Down Expand Up @@ -533,6 +534,7 @@ def linkbaseTopElts():
if l > 200:
val.modelXbrl.error("EFM.6.07.29",
_("Schema %(element)s has a name length (%(length)s) over 200 bytes long in utf-8, %(name)s."),
edgarCode="du-0729-Name-Length-Limit",
modelObject=elt, element=localName, name=name, length=l)

if val.validateSBRNL and localName in {"all", "documentation", "any", "anyAttribute", "attributeGroup",
Expand Down
20 changes: 9 additions & 11 deletions arelle/XhtmlValidate.py
Expand Up @@ -11,7 +11,7 @@
from arelle.ModelObject import ModelObject
from arelle.PythonUtil import normalizeSpace
from lxml import etree
import os, re
import os, re, posixpath

EMPTYDICT = {}

Expand Down Expand Up @@ -562,13 +562,11 @@ def resolveHtmlUri(elt, name, value):
if elt.modelDocument.htmlBase is not None:
value = elt.modelDocument.htmlBase + value
# canonicalize ../ and ./
authority, sep, path = value.rpartition("://")
inpaths = path.split("/")
outpaths = []
for path in inpaths:
if path == "..":
if len(outpaths) > 1:
outpaths.pop()
elif path != "." and (path != "" or len(outpaths) == 0):
outpaths.append(path.replace(" ", "%20"))
return authority + sep + "/".join(outpaths)
scheme, sep, pathpart = value.rpartition("://")
if sep:
pathpart = pathpart.replace('\\','/')
endingSep = '/' if pathpart[-1] == '/' else '' # normpath drops ending directory separator
_uri = scheme + "://" + posixpath.normpath(pathpart) + endingSep
else:
_uri = os.path.normpath(value)
return _uri.replace(" ", "%20")
1 change: 1 addition & 0 deletions arelle/config/disclosuresystems.xsd
Expand Up @@ -60,6 +60,7 @@
<xs:attribute name="mappingsUrl" />
<xs:attribute name="utrUrl" />
<xs:attribute name="validateFileText" type="xs:boolean"/>
<xs:attribute name="allowedExternalHrefPattern" type="xs:string"/>
<xs:attribute name="blockDisallowedReferences" type="xs:boolean"/>
<xs:attribute name="maxSubmissionSubdirectoryEntryNesting" type="xs:integer"/>
<xs:attribute name="logLevelFilter" />
Expand Down

0 comments on commit 1f3535a

Please sign in to comment.