Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package urlscan for openSUSE:Factory checked in at 2022-12-06 15:52:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/urlscan (Old) and /work/SRC/openSUSE:Factory/.urlscan.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "urlscan" Tue Dec 6 15:52:16 2022 rev:12 rq:1040672 version:0.9.10 Changes: -------- --- /work/SRC/openSUSE:Factory/urlscan/urlscan.changes 2022-08-05 19:51:49.081582248 +0200 +++ /work/SRC/openSUSE:Factory/.urlscan.new.1835/urlscan.changes 2022-12-06 15:52:16.891849065 +0100 @@ -1,0 +2,8 @@ +Tue Dec 6 13:06:46 UTC 2022 - Dirk Müller <[email protected]> + +- update to 0.9.10: + * Add "*" to allowed URL characters. Fix #125 + * Strip whitespace from URLs. Fixes #124 + * Redo redirection of sterr/stdout. Fix #122 + +------------------------------------------------------------------- Old: ---- urlscan-0.9.9.tar.gz New: ---- urlscan-0.9.10.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ urlscan.spec ++++++ --- /var/tmp/diff_new_pack.9eVbr2/_old 2022-12-06 15:52:17.411851974 +0100 +++ /var/tmp/diff_new_pack.9eVbr2/_new 2022-12-06 15:52:17.419852018 +0100 @@ -18,7 +18,7 @@ %define python_flavor python3 Name: urlscan -Version: 0.9.9 +Version: 0.9.10 Release: 0 Summary: An other URL extractor/viewer License: GPL-2.0-or-later ++++++ urlscan-0.9.9.tar.gz -> urlscan-0.9.10.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.9/setup.py new/urlscan-0.9.10/setup.py --- old/urlscan-0.9.9/setup.py 2022-01-29 05:38:35.000000000 +0100 +++ new/urlscan-0.9.10/setup.py 2022-08-04 00:35:50.000000000 +0200 @@ -11,14 +11,14 @@ setup(name="urlscan", - version="0.9.9", + version="0.9.10", description="View/select the URLs in an email message or file", long_description=long_description(), long_description_content_type="text/markdown", author="Scott Hansen", author_email="[email protected]", url="https://github.com/firecat53/urlscan", - download_url="https://github.com/firecat53/urlscan/archive/0.9.9.zip", + download_url="https://github.com/firecat53/urlscan/archive/0.9.10.zip", packages=['urlscan'], entry_points={ 'console_scripts': ['urlscan=urlscan.__main__:main'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.9/urlscan/urlchoose.py new/urlscan-0.9.10/urlscan/urlchoose.py --- old/urlscan-0.9.9/urlscan/urlchoose.py 2022-01-29 05:38:35.000000000 +0100 +++ new/urlscan-0.9.10/urlscan/urlchoose.py 2022-08-04 00:35:50.000000000 +0200 @@ -18,6 +18,7 @@ """An urwid listview-based widget that lets you choose a URL from a list of URLs.""" +import contextlib import json import os from os.path import dirname, exists, expanduser @@ -353,7 +354,7 @@ def _background_queue(self, mode): """Open URLs in background""" for url in self.queue: - self.mkbrowseto(url, thread=True, mode=mode)() + self.mkbrowseto(url, mode=mode)() self.draw_screen() def _queue(self, mode=2): @@ -744,48 +745,41 @@ self.header.format(self.link_open_modes[0], len(self.queue))), 'header') self.top.base_widget.header = self.headerwid - def mkbrowseto(self, url, thread=False, mode=0): + def mkbrowseto(self, url, mode=0): """Create the urwid callback function to open the web browser or call another function with the URL. """ def browse(*args): # pylint: disable=unused-argument - # These 3 lines prevent any stderr messages from webbrowser or xdg - savout = os.dup(2) - os.close(2) - os.open(os.devnull, os.O_RDWR) # double ()() to ensure self.search evaluated at runtime, not when # browse() is _created_. [0] is self.search, [1] is self.enter # self.enter prevents opening URL when in search mode - if self._get_search()[0]() is True: - if self._get_search()[1]() is True: - self.search = False - self.enter = False - elif self.link_open_modes[0] == "Web Browser": - webbrowser.open(url, new=mode) - elif self.link_open_modes[0] == "Xdg-Open": - subprocess.run(shlex.split(f'xdg-open "{url}"'), check=False) - elif self.link_open_modes[0] == self.runsafe: - if self.pipe: - subprocess.run(shlex.split(self.runsafe), + with redirect_output(): + if self._get_search()[0]() is True: + if self._get_search()[1]() is True: + self.search = False + self.enter = False + elif self.link_open_modes[0] == "Web Browser": + webbrowser.open(url, new=mode) + elif self.link_open_modes[0] == "Xdg-Open": + subprocess.run(shlex.split(f'xdg-open "{url}"'), check=False) + elif self.link_open_modes[0] == self.runsafe: + if self.pipe: + subprocess.run(shlex.split(self.runsafe), + check=False, + input=url.encode(sys.getdefaultencoding())) + else: + cmd = [i.format(url) for i in shlex.split(self.runsafe)] + subprocess.run(cmd, check=False) + elif self.link_open_modes[0] == self.run and self.pipe: + subprocess.run(shlex.split(self.run), check=False, input=url.encode(sys.getdefaultencoding())) else: - cmd = [i.format(url) for i in shlex.split(self.runsafe)] - subprocess.run(cmd, check=False) - elif self.link_open_modes[0] == self.run and self.pipe: - subprocess.run(shlex.split(self.run), - check=False, - input=url.encode(sys.getdefaultencoding())) - else: - subprocess.run(self.run.format(url), check=False, shell=True) + subprocess.run(self.run.format(url), check=False, shell=True) - if self.single is True: - self._quit() - # Restore normal stderr - os.dup2(savout, 2) - if thread is False: - self.draw_screen() + if self.single is True: + self._quit() return browse def process_urls(self, extractedurls, dedupe, shorten): @@ -820,6 +814,7 @@ if chunk.url is None: markup.append(('msgtext', chunk.markup)) else: + chunk.url = chunk.url.strip() if (dedupe is True and chunk.url not in urls) \ or dedupe is False: urls.append(chunk.url) @@ -830,7 +825,8 @@ if chunk.markup: tmpmarkup.append(('msgtext', chunk.markup)) while i < len(chunks) and \ - chunks[i].url == chunk.url: + (chunks[i].url if chunks[i].url is None + else chunks[i].url.strip()) == chunk.url: if chunks[i].markup: tmpmarkup.append(chunks[i].markup) i += 1 @@ -861,3 +857,29 @@ items.append(urwid.Columns(markup)) return items, urls + + [email protected] +def redirect_output(): + """ + A context manager to temporarily redirect stderr and stdout to devnull + + Usage: + with redirect_output(): + webbrowser.open('https://google.com') + + """ + try: + err = os.dup(sys.stderr.fileno()) + out = os.dup(sys.stdout.fileno()) + dest_file = open(os.devnull, 'w') + os.dup2(dest_file.fileno(), sys.stderr.fileno()) + os.dup2(dest_file.fileno(), sys.stdout.fileno()) + yield + finally: + if err is not None: + os.dup2(err, sys.stderr.fileno()) + if out is not None: + os.dup2(out, sys.stdout.fileno()) + if dest_file is not None: + dest_file.close() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/urlscan-0.9.9/urlscan/urlscan.py new/urlscan-0.9.10/urlscan/urlscan.py --- old/urlscan-0.9.9/urlscan/urlscan.py 2022-01-29 05:38:35.000000000 +0100 +++ new/urlscan-0.9.10/urlscan/urlscan.py 2022-08-04 00:35:50.000000000 +0200 @@ -245,7 +245,7 @@ self.handle_data(f"&{name};") -URLINTERNALPATTERN = r'[{}()@\w/\\\-%?!&.=:;+,#~]' +URLINTERNALPATTERN = r'[{}()@\w/\\\-%?!&.=:;+,#~*]' URLTRAILINGPATTERN = r'[{}(@\w/\-%&=+#$]' HTTPURLPATTERN = (r'(?:(https?|file|ftps?)://' + URLINTERNALPATTERN + r'*' + URLTRAILINGPATTERN + r')')
