'))
self.assertTrue(p.markdown().find('href="javascript:') == -1)
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'[link](javascript:alert(1))'))
self.assertTrue(p.markdown().find('href="javascript:') == -1)
def test_string_markdown_forced_line_break(self):
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'This is a set of text \n:that should have a break \n:at newlines. Each \n:colon should be the start of an html line'))
# sigh different backends render this differently:
# of text
# of text
# etc.
# Rather than using a different result for each
# renderer, look for '
\n\n```\nline 1\nline 2\n```\n\nnew paragraph'))
self.assertEqual(p.markdown().strip().replace('\n\n', '\n'), u2s(u'embedded code block <pre>
\nline 1\nline 2\n
\nnew </pre> paragraph
'))
def test_string_markdown_code_block_attribute(self):
''' also verify that embedded html is escaped '''
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'embedded code block \n\n``` python\nline 1\nline 2\n```\n\nnew
paragraph'))
m = p.markdown().strip()
print(m)
if type(self) == MistuneTestCase:
self.assertEqual(m.replace('\n\n','\n'), 'embedded code block <pre>
\nline 1\nline 2\n
\nnew </pre> paragraph
')
elif type(self) == MarkdownTestCase:
self.assertEqual(m.replace('\n\n','\n'), 'embedded code block <pre>
\nline 1\nline 2\n
\nnew </pre> paragraph
')
else:
self.assertEqual(m.replace('\n\n', '\n'), 'embedded code block <pre>
\n\nnew </pre> paragraph
')
def test_markdown_return_text_on_exception(self):
''' string is invalid markdown. missing end of fenced code block '''
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'embedded code block \n\n``` python\nline 1\nline 2\n\n\nnew
paragraph'))
m = p.markdown().strip()
print(m)
self.assertEqual(m.replace('\n\n','\n'), 'embedded code block <pre>
\n``` python\nline 1\nline 2
\nnew </pre> paragraph
')
def test_markdown_break_on_newline(self):
self.client.db.config['MARKDOWN_BREAK_ON_NEWLINE'] = True
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with\nline break\ntwice.'))
m = p.markdown()
self.assertEqual(2, m.count('
*embedded* \u00df'))
self.assertEqual(p.markdown(), u2s(u'A string http://localhost with cmeerw@example.com <br> *embedded* \u00df'))
class NoRstTestCase(TemplatingTestCase) :
def setUp(self):
TemplatingTestCase.setUp(self)
from roundup.cgi import templating
self.__ReStructuredText = templating.ReStructuredText
templating.ReStructuredText = None
def tearDown(self):
from roundup.cgi import templating
templating.ReStructuredText = self.__ReStructuredText
def test_string_rst(self):
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with cmeerw@example.com *embedded* \u00df'))
self.assertEqual(p.rst(), u2s(u'A string with cmeerw@example.com *embedded* \u00df'))
class NoStextTestCase(TemplatingTestCase) :
def setUp(self):
TemplatingTestCase.setUp(self)
from roundup.cgi import templating
self.__StructuredText = templating.StructuredText
templating.StructuredText = None
def tearDown(self):
from roundup.cgi import templating
templating.StructuredText = self.__StructuredText
def test_string_stext(self):
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with cmeerw@example.com *embedded* \u00df'))
self.assertEqual(p.stext(), u2s(u'A string with cmeerw@example.com *embedded* \u00df'))
r'''
class HTMLPermissions:
def is_edit_ok(self):
def is_view_ok(self):
def is_only_view_ok(self):
def view_check(self):
def edit_check(self):
def input_html4(**attrs):
def input_xhtml(**attrs):
class HTMLInputMixin:
def __init__(self):
class HTMLClass(HTMLInputMixin, HTMLPermissions):
def __init__(self, client, classname, anonymous=0):
def __repr__(self):
def __getitem__(self, item):
def __getattr__(self, attr):
def designator(self):
def getItem(self, itemid, num_re=re.compile(r'-?\d+')):
def properties(self, sort=1, cansearch=True):
def list(self, sort_on=None):
def csv(self):
def propnames(self):
def filter(self, request=None, filterspec={}, sort=(None,None),
def classhelp(self, properties=None, label='(list)', width='500',
def submit(self, label="Submit New Entry"):
def history(self):
def renderWith(self, name, **kwargs):
class HTMLItem(HTMLInputMixin, HTMLPermissions):
def __init__(self, client, classname, nodeid, anonymous=0):
def __repr__(self):
def __getitem__(self, item):
def __getattr__(self, attr):
def designator(self):
def is_retired(self):
def submit(self, label="Submit Changes"):
def journal(self, direction='descending'):
def history(self, direction='descending', dre=re.compile('\d+')):
def renderQueryForm(self):
class HTMLUserPermission:
def is_edit_ok(self):
def is_view_ok(self):
def _user_perm_check(self, type):
class HTMLUserClass(HTMLUserPermission, HTMLClass):
class HTMLUser(HTMLUserPermission, HTMLItem):
def __init__(self, client, classname, nodeid, anonymous=0):
def hasPermission(self, permission, classname=_marker):
class HTMLProperty(HTMLInputMixin, HTMLPermissions):
def __init__(self, client, classname, nodeid, prop, name, value,
def __repr__(self):
def __str__(self):
def __lt__(self, other):
def __le__(self, other):
def __eq__(self, other):
def __ne__(self, other):
def __gt__(self, other):
def __ge__(self, other):
def is_edit_ok(self):
def is_view_ok(self):
class StringHTMLProperty(HTMLProperty):
def _hyper_repl(self, match):
def hyperlinked(self):
def plain(self, escape=0, hyperlink=0):
def stext(self, escape=0):
def field(self, size = 30):
def multiline(self, escape=0, rows=5, cols=40):
def email(self, escape=1):
class PasswordHTMLProperty(HTMLProperty):
def plain(self):
def field(self, size = 30):
def confirm(self, size = 30):
class NumberHTMLProperty(HTMLProperty):
def plain(self):
def field(self, size = 30):
def __int__(self):
def __float__(self):
class IntegerHTMLProperty(HTMLProperty):
def plain(self):
def field(self, size = 30):
def __int__(self):
class BooleanHTMLProperty(HTMLProperty):
def plain(self):
def field(self):
class DateHTMLProperty(HTMLProperty):
def plain(self):
def now(self):
def field(self, size = 30):
def reldate(self, pretty=1):
def pretty(self, format=_marker):
def local(self, offset):
class IntervalHTMLProperty(HTMLProperty):
def plain(self):
def pretty(self):
def field(self, size = 30):
class LinkHTMLProperty(HTMLProperty):
def __init__(self, *args, **kw):
def __getattr__(self, attr):
def plain(self, escape=0):
def field(self, showid=0, size=None):
def menu(self, size=None, height=None, showid=0, additional=[],
class MultilinkHTMLProperty(HTMLProperty):
def __init__(self, *args, **kwargs):
def __len__(self):
def __getattr__(self, attr):
def __getitem__(self, num):
def __contains__(self, value):
def reverse(self):
def sorted(self, property, reverse=False):
def plain(self, escape=0):
def field(self, size=30, showid=0):
def menu(self, size=None, height=None, showid=0, additional=[],
def make_key_function(db, classname, sort_on=None):
def keyfunc(a):
def find_sort_key(linkcl):
def handleListCGIValue(value):
class ShowDict:
def __init__(self, columns):
def __getitem__(self, name):
class HTMLRequest(HTMLInputMixin):
def __init__(self, client):
def _post_init(self):
def updateFromURL(self, url):
def update(self, kwargs):
def description(self):
def __str__(self):
def indexargs_form(self, columns=1, sort=1, group=1, filter=1,
def indexargs_url(self, url, args):
def base_javascript(self):
def batch(self):
class Batch(ZTUtils.Batch):
def __init__(self, client, sequence, size, start, end=0, orphan=0,
def __getitem__(self, index):
def propchanged(self, property):
def previous(self):
def next(self):
#class TemplatingUtils:
# def __init__(self, client):
# def Batch(self, sequence, size, start, end=0, orphan=0, overlap=0):
class NoTemplate(Exception):
class Unauthorised(Exception):
def __init__(self, action, klass):
def __str__(self):
class Loader:
def __init__(self, dir):
def precompileTemplates(self):
def load(self, name, extension=None):
def __getitem__(self, name):
class RoundupPageTemplate(PageTemplate.PageTemplate):
def getContext(self, client, classname, request):
def render(self, client, classname, request, **options):
def __repr__(self):
'''
# vim: set et sts=4 sw=4 :