Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for attr, value in attrib:
if attr in boolean_attrs:
value = attr
elif attr == 'xml:lang' and 'lang' not in attrib:
buf += [' lang="', escape(value), '"']
elif attr == 'xml:space':
continue
buf += [' ', attr, '="', escape(value), '"']
if kind is EMPTY:
if tag in empty_elems:
buf.append(' />')
else:
buf.append('>' % tag)
else:
buf.append('>')
yield _emit(kind, data, Markup(''.join(buf)))
elif kind is END:
yield _emit(kind, data, Markup('' % data))
elif kind is TEXT:
if in_cdata:
yield _emit(kind, data, data)
else:
yield _emit(kind, data, escape(data, quotes=False))
elif kind is COMMENT:
yield _emit(kind, data, Markup('' % data))
elif kind is DOCTYPE and not have_doctype:
name, pubid, sysid = data
buf = ['
tag, attrib = data
buf = ['<', tag]
for attr, value in attrib:
if attr in boolean_attrs:
if value:
buf += [' ', attr]
elif ':' in attr:
if attr == 'xml:lang' and u'lang' not in attrib:
buf += [' lang="', escape(value), '"']
elif attr != 'xmlns':
buf += [' ', attr, '="', escape(value), '"']
buf.append('>')
if kind is EMPTY:
if tag not in empty_elems:
buf.append('' % tag)
yield Markup(u''.join(buf))
if tag in noescape_elems:
noescape = True
elif kind is END:
yield Markup('' % data)
noescape = False
elif kind is TEXT:
if noescape:
yield data
else:
yield escape(data, quotes=False)
elif kind is COMMENT:
yield Markup('' % data)
if np.errorlevel or np.err:
self.env.disable_component(self)
err = "Running enscript failed with (%s, %s), disabling " \
"EnscriptRenderer (command: '%s')" \
% (np.errorlevel, np.err.strip(), cmdline)
raise Exception(err)
odata = np.out
# Strip header and footer
i = odata.find('<pre>')
beg = i > 0 and i + 6
i = odata.rfind('</pre>')
end = i if i > 0 else len(odata)
odata = EnscriptDeuglifier().format(odata[beg:end].decode('utf-8'))
return [Markup(line) for line in odata.splitlines()]
def preprocessTableCell(td):
if(isinstance(td,(list,tuple))):
if(len(td) >= 2):
return (Markup(str(td[0])),Markup(str(td[1])))
elif(len(td) == 1):
return (Markup(str(td[0])),Markup(TableDecorator.WHITE))
else:
return ('',Markup(TableDecorator.WHITE))
else:
return (Markup(str(td)),Markup(TableDecorator.WHITE))
yield escape(data, quotes=False)
elif kind is COMMENT:
yield Markup('' % data)
elif kind is DOCTYPE and not have_doctype:
name, pubid, sysid = data
buf = ['\n')
yield Markup(u''.join(buf)) % filter(None, data)
have_doctype = True
elif kind is PI:
yield Markup('' % data)
def istext(text):
"""`True` for text (`unicode` and `str`), but `False` for `Markup`."""
from genshi.core import Markup
return isinstance(text, basestring) and not isinstance(text, Markup)
def striptags(self):
"""Return a copy of the text with all XML/HTML tags removed.
:return: a `Markup` instance with all tags removed
:rtype: `Markup`
:see: `genshi.util.striptags`
"""
return Markup(striptags(self))
def _make_sublink(self, env, sublink, formatter, ns, target, label,
fullmatch, extra=''):
parent_match = {'ns' : ns,
'target' : target,
'label': Markup(escape(unescape(label)
if isinstance(label, Markup)
else label)),
'fullmatch' : fullmatch,
}
# Tweak nested context to work in target product/global scope
subctx = formatter.context.child()
subctx.href = resolve_product_href(to_env=env, at_env=self.env)
try:
req = formatter.context.req
except AttributeError:
pass
else:
# Authenticate in local context but use foreign permissions
subctx.perm = self.FakePermClass() \
if isinstance(req.session, FakeSession) \
def render_js_player(self):
return Markup("new mcore.Html5Player()")
def renderULGError(self,sessionid=None,**params):
template = self.loader.load(defaults.index_template_file)
result_text = defaults.STRING_ARBITRARY_ERROR
session = loadSession(sessionid)
if(session!=None):
result_text=self.decorator_helper.pre(self.sessions[sessionid].getError())
return template.generate(defaults=defaults,
routers=config.routers,
commonparams=self.getCommonParams(),
default_routerid=0,
default_commandid=0,
default_sessionid=None,
result=Markup(result_text) if(result_text) else None,
refresh=0,
getFormURL=self.decorator_helper.getRuncommandURL,
user=self.user
).render('html', doctype='html', encoding='utf-8')