Scrapy, a fast high-level web crawling & scraping framework for Python.
Mention open_in_browser in the release notes
Adrián Chaveseb8b2c5197f3
diff --git a/docs/news.rst b/docs/news.rstindex 121cc0322..2bbe833a5 100644--- a/docs/news.rst+++ b/docs/news.rst@@ -10,10 +10,10 @@ Scrapy 2.11.1 (unreleased)**Security bug fix:**-- The regular expressions of the ``iternodes`` node iterator of- :class:`~scrapy.spiders.XMLFeedSpider` are no longer susceptible to a- `ReDoS attack`_. Please, see the `cc65-xxvf-f7r9 security- advisory`_ for more information.+- Fixed regular expressions susceptible to a `ReDoS attack`_ affecting the+ ``iternodes`` node iterator of :class:`~scrapy.spiders.XMLFeedSpider` and+ the :func:`~scrapy.utils.response.open_in_browser` function. Please, see+ the `cc65-xxvf-f7r9 security advisory`_ for more information... _ReDoS attack: https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS.. _cc65-xxvf-f7r9 security advisory: https://github.com/scrapy/scrapy/security/advisories/GHSA-cc65-xxvf-f7r9@@ -2892,10 +2892,10 @@ Scrapy 1.8.4 (unreleased)**Security bug fix:**-- The regular expressions of the ``iternodes`` node iterator of- :class:`~scrapy.spiders.XMLFeedSpider` are no longer susceptible to a- `ReDoS attack`_. Please, see the `cc65-xxvf-f7r9 security- advisory`_ for more information.+- Fixed regular expressions susceptible to a `ReDoS attack`_ affecting the+ ``iternodes`` node iterator of :class:`~scrapy.spiders.XMLFeedSpider` and+ the :func:`~scrapy.utils.response.open_in_browser` function. Please, see+ the `cc65-xxvf-f7r9 security advisory`_ for more information... _release-1.8.3:diff --git a/docs/topics/debug.rst b/docs/topics/debug.rstindex 49c5b0410..988e37bbd 100644--- a/docs/topics/debug.rst+++ b/docs/topics/debug.rst@@ -125,26 +125,16 @@ Fortunately, the :command:`shell` is your bread and butter in this case (seeSee also: :ref:`topics-shell-inspect-response`.+Open in browser===============Sometimes you just want to see how a certain response looks in a browser, you-can use the ``open_in_browser`` function for that. Here is an example of how-you would use it:--.. code-block:: python+can use the :func:`~scrapy.utils.response.open_in_browser` function for that:- from scrapy.utils.response import open_in_browser+.. autofunction:: scrapy.utils.response.open_in_browser- def parse_details(self, response):- if "item name" not in response.body:- open_in_browser(response)--``open_in_browser`` will open a browser with the response received by Scrapy at-that point, adjusting the `base tag`_ so that images and styles are displayed-properly.-Logging=======@@ -163,8 +153,6 @@ available in all future runs should they be necessary again:For more information, check the :ref:`topics-logging` section.-.. _base tag: https://www.w3schools.com/tags/tag_base.asp-.. _debug-vscode:Visual Studio Codediff --git a/scrapy/utils/response.py b/scrapy/utils/response.pyindex b0e106c5e..8401d4ed1 100644--- a/scrapy/utils/response.py+++ b/scrapy/utils/response.py@@ -81,8 +81,21 @@ def open_in_browser(],_openfunc: Callable[[str], Any] = webbrowser.open,) -> Any:- """Open the given response in a local web browser, populating the <base>- tag for external links to work+ """Open *response* in a local web browser, adjusting the `base tag`_ for+ external links to work, e.g. so that images and styles are displayed.++ .. _base tag: https://www.w3schools.com/tags/tag_base.asp++ For example:++ .. code-block:: python++ from scrapy.utils.response import open_in_browser+++ def parse_details(self, response):+ if "item name" not in response.body:+ open_in_browser(response)"""from scrapy.http import HtmlResponse, TextResponse