Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def callback():
try:
callback_uri = url_for('.callback', _external=True)
result = process_callback(callback_uri)
if 'error' in result:
flash(result['error'], category='danger')
return redirect(url_for('views.index'))
account = result['account']
return redirect(url_for('views.setup_account', service=SERVICE_NAME,
user_id=account.user_id))
except:
current_app.logger.exception('During Twitter authorization callback')
flash(html.escape(str(sys.exc_info()[0])), 'danger')
return redirect(url_for('views.index'))
def dumpdata(place, data) :
retval = ""
if len(data) > 0 :
retval += '<p>Incoming '+place+' data:<br>\n'
for key, value in data.items():
retval += html.escape(key) + '=' + html.escape(value) + '<br>\n'
retval += '</p>\n'
return retval
is called to update the status bar
"""
if self.active_downloads:
# add a newline before we list downloads
result = ' downloads:'
for path, progress in list(self.active_downloads.items()):
# add each download
fn = os.path.basename(path)
dl = " %s (%d%%)" % (fn, progress * 100)
# replace entities to make sure we don't break our markup
# (this could be done with an @[]@ expansion in uzbl, but then we
# can't use the above to make a new line)
dl = escape(dl)
result += dl
else:
result = ''
# and the result gets saved to an uzbl variable that can be used in
# status_format
config = Config[self.uzbl]
if config.get('downloads', None) != result:
config['downloads'] = result
def get_html_summary(self):
version = self.get_field('csharp.version')
start_mode = self.get_field('csharp.start_mode')
executable = self.get_field('csharp.executable')
working_directory = self.get_field('csharp.working_directory')
options = ' '.join(self.option_list_editor.get_items())
html_text = 'Mono Version: {0}<br>'.format(html.escape(self.combo_version.itemText(version)))
html_text += 'Start Mode: {0}<br>'.format(html.escape(Constants.csharp_start_mode_display_names[start_mode]))
if start_mode == Constants.CSHARP_START_MODE_EXECUTABLE:
html_text += 'Executable: {0}<br>'.format(html.escape(executable))
html_text += 'Working Directory: {0}<br>'.format(html.escape(working_directory))
html_text += 'Mono Options: {0}<br>'.format(html.escape(options))
return html_text
def get_date(self, date):
""" return a formatted date """
return html.escape(self._get_date(date))
for i in range(xlo, xhi):
rx1.append('-')
rx2.append(x[i])
ry1 = []
ry2 = []
for i in range(ylo, yhi):
ry1.append('+')
ry2.append(y[i])
r.append('\n'
'<pre>\n%s\n%s\n</pre>\n'
'<pre>\n%s\n%s\n</pre>\n'
'\n'
% ('\n'.join(rx1), '\n'.join(ry1),
escape('\n'.join(rx2)), escape('\n'.join(ry2))))
def html_quote(value, force=True):
if not force and hasattr(value, '__html__'):
return value.__html__()
if value is None:
return ''
if not isinstance(value, basestring_):
value = coerce_text(value)
if sys.version >= "3" and isinstance(value, bytes):
value = html_escape(value.decode('latin1'), 1)
value = value.encode('latin1')
else:
value = html_escape(value, 1)
if sys.version < "3":
if is_unicode(value):
value = value.encode('ascii', 'xmlcharrefreplace')
return value
Return family label string (with tags).
"""
# start main html table
label = ('')
# add dates strtings to table
event_str = ''
for event_ref in family.get_event_ref_list():
event = self.database.get_event_from_handle(event_ref.ref)
if (event.type == EventType.MARRIAGE and
(event_ref.get_role() == EventRoleType.FAMILY or
event_ref.get_role() == EventRoleType.PRIMARY)):
event_str = self.get_event_string(event)
break
label += '' % escape(event_str)
# add tags table for family and add tooltip for node
if self.show_tag_color:
tags, tag_table = self.get_tags_and_table(family)
if tag_table:
label += '' % tag_table
self.add_tags_tooltip(family.handle, tags)
# close main table
label += '<table cellpadding="0" cellspacing="2"><tbody><tr><td>%s</td></tr><tr><td>%s</td></tr></tbody></table>'
return label
def logSender(self, text, message: PeerInfo, short=False):
text_msg = text.replace('%sender%', self.printableSender(message, False, short=short))
html_msg = html.escape(text).replace('%sender%', self.printableSender(message, True, short=short))
logging.info(text_msg, extra={'db': html_msg})
def get_html_summary(self):
flavor = self.get_field('javascript.flavor')
start_mode = self.get_field('javascript.start_mode')
script_file = self.get_field('javascript.script_file')
command = self.get_field('javascript.command')
working_directory = self.get_field('javascript.working_directory')
options = ' '.join(self.option_list_editor.get_items())
html_text = 'JavaScript Flavor: {0}<br>'.format(html.escape(self.combo_flavor.itemText(flavor)))
if flavor == Constants.JAVASCRIPT_FLAVOR_NODEJS:
html_text += 'Start Mode: {0}<br>'.format(html.escape(Constants.javascript_start_mode_display_names[start_mode]))
if start_mode == Constants.JAVASCRIPT_START_MODE_SCRIPT_FILE:
html_text += 'Script File: {0}<br>'.format(html.escape(script_file))
elif start_mode == Constants.JAVASCRIPT_START_MODE_COMMAND:
html_text += 'Command: {0}<br>'.format(html.escape(command))
html_text += 'Working Directory: {0}<br>'.format(html.escape(working_directory))
html_text += 'Node.js Options: {0}<br>'.format(html.escape(options))
return html_text