Sitelet https://github.com/gpodder/gpodder/pull/1276/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/gpodder/gtkui/interface/addpodcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def new(self):
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

def receive_clipboard_text(clipboard, text, second_try):
# Heuristic: If there is a space in the clipboard
# text, assume it's some arbitrary text, and no URL
if text is not None and ' ' not in text:
# Heuristic: If space is present in clipboard text
# normalize_feed_url will either fix to valid url or
# return None if URL cannot be validated
if text is not None:
url = util.normalize_feed_url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fgpodder%2Fgpodder%2Fpull%2F1276%2Ftext)
if url is not None:
self.entry_url.set_text(url)
Expand All @@ -72,7 +73,7 @@ def on_btn_paste_clicked(self, widget):

def receive_clipboard_text(self, clipboard, text, data=None):
if text is not None:
self.entry_url.set_text(text)
self.entry_url.set_text(text).strip()
else:
self.show_message(_('Nothing to paste.'), _('Clipboard is empty'))

Expand Down
10 changes: 8 additions & 2 deletions src/gpodder/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
try:
import html5lib
except ImportError:
logger.warn('html5lib not found, falling back to HTMLParser')
logger.warning("html5lib was not found, fall-back to HTMLParser")
html5lib = None

if gpodder.ui.win32:
try:
import gpodder.utilwin32ctypes as win32file
except ImportError:
logger.warn('Running on Win32 but utilwin32ctypes can\'t be loaded.')
logger.warning('Running on Win32: utilwin32ctypes cannot be loaded')
win32file = None

_ = gpodder.gettext
Expand Down Expand Up @@ -248,6 +248,12 @@ def normalize_feed_url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fgpodder%2Fgpodder%2Fpull%2F1276%2Furl):
if not url or len(url) < 8:
return None

# Removes leading and/or trailing whitespaces - if url contains whitespaces
# in between after str.strip() -> conclude invalid url & return None
url = url.strip()
if ' ' in url:
return None

# This is a list of prefixes that you can use to minimize the amount of
# keystrokes that you have to use.
# Feel free to suggest other useful prefixes, and I'll add them here.
Expand Down