prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  plone-upgrade to 5.0.3 shows plain text as result
  This is caused by https://github.com/plone/plone.app.upgrade/pull/67 by @vangheem, though this change looks fine to me.
  
  With the above change, when running `@@plone-upgrade`, even with dry-run selected, the result page is shown as text: you see plain html. Very strange. Reported here: https://community.plone.org/t/plone-5-0-3-soft-released/1699/4
  When I empty the registry.xml, keeping only the main `registry` tags for safety, it all works fine. Keeping one of the two changed records, it again shows as text.
  
  To check it:
  - Use current coredev 5.0
  - Create a Plone Site.
  - Simulate a Plone 5.0.2 site: in portal_setup, Upgrades, select Products.CMFPlone:plone, and run the to502 upgrade profile.
  - Go to @@plone-upgrade, optionally select dry-run, and run the upgrade.
  
  Result: it will show as plain text.
  BTW, afterwards, all is fine: the migration has succeeded and it looks like all pages show up fine.
  
  Any idea?
  
  
  </issue>
  <code>
  [start of Products/CMFPlone/resources/exportimport/bundles.py]
  1 from plone.registry.interfaces import IRegistry
  2 from zope.component import queryUtility
  3 
  4 from ..browser.combine import combine_bundles
  5 
  6 
  7 def combine(context):
  8 
  9     logger = context.getLogger('bundles')
  10     registry = queryUtility(IRegistry)
  11 
  12     if registry is None:
  13         logger.info("Cannot find registry")
  14         return
  15 
  16     body = context.readDataFile('registry.xml')
  17     if body and "IBundleRegistry" in body:
  18         site = context.getSite()
  19         combine_bundles(site)
  20
  [end of Products/CMFPlone/resources/exportimport/bundles.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/Products/CMFPlone/resources/exportimport/bundles.py b/Products/CMFPlone/resources/exportimport/bundles.py
  --- a/Products/CMFPlone/resources/exportimport/bundles.py
  +++ b/Products/CMFPlone/resources/exportimport/bundles.py
  @@ -1,5 +1,6 @@
   from plone.registry.interfaces import IRegistry
   from zope.component import queryUtility
  +from zope.globalrequest import getRequest
   
   from ..browser.combine import combine_bundles
   
  @@ -16,4 +17,20 @@
       body = context.readDataFile('registry.xml')
       if body and "IBundleRegistry" in body:
           site = context.getSite()
  +        # Calling combine_bundles will have as side effect that the
  +        # Content-Type header of the response is set to application/javascript,
  +        # which we do not want.  So we reset it to the original at the end.
  +        site = context.getSite()
  +        request = getattr(site, 'REQUEST', getRequest())
  +        if request is not None:
  +            # Easily happens in tests.
  +            orig_header = request.response.getHeader('Content-Type')
           combine_bundles(site)
  +        if request is not None:
  +            new_header = request.response.getHeader('Content-Type')
  +            if new_header != orig_header:
  +                if orig_header is None:
  +                    # Setting it to None would result in the string 'None'.
  +                    # So pick a saner one.
  +                    orig_header = 'text/html'
  +                request.response.setHeader('Content-Type', orig_header)
  
verification_info: {"golden_diff": "diff --git a/Products/CMFPlone/resources/exportimport/bundles.py b/Products/CMFPlone/resources/exportimport/bundles.py\n--- a/Products/CMFPlone/resources/exportimport/bundles.py\n+++ b/Products/CMFPlone/resources/exportimport/bundles.py\n@@ -1,5 +1,6 @@\n from plone.registry.interfaces import IRegistry\n from zope.component import queryUtility\n+from zope.globalrequest import getRequest\n \n from ..browser.combine import combine_bundles\n \n@@ -16,4 +17,20 @@\n     body = context.readDataFile('registry.xml')\n     if body and \"IBundleRegistry\" in body:\n         site = context.getSite()\n+        # Calling combine_bundles will have as side effect that the\n+        # Content-Type header of the response is set to application/javascript,\n+        # which we do not want.  So we reset it to the original at the end.\n+        site = context.getSite()\n+        request = getattr(site, 'REQUEST', getRequest())\n+        if request is not None:\n+            # Easily happens in tests.\n+            orig_header = request.response.getHeader('Content-Type')\n         combine_bundles(site)\n+        if request is not None:\n+            new_header = request.response.getHeader('Content-Type')\n+            if new_header != orig_header:\n+                if orig_header is None:\n+                    # Setting it to None would result in the string 'None'.\n+                    # So pick a saner one.\n+                    orig_header = 'text/html'\n+                request.response.setHeader('Content-Type', orig_header)\n", "issue": "plone-upgrade to 5.0.3 shows plain text as result\nThis is caused by https://github.com/plone/plone.app.upgrade/pull/67 by @vangheem, though this change looks fine to me.\n\nWith the above change, when running `@@plone-upgrade`, even with dry-run selected, the result page is shown as text: you see plain html. Very strange. Reported here: https://community.plone.org/t/plone-5-0-3-soft-released/1699/4\nWhen I empty the registry.xml, keeping only the main `registry` tags for safety, it all works fine. Keeping one of the two changed records, it again shows as text.\n\nTo check it:\n- Use current coredev 5.0\n- Create a Plone Site.\n- Simulate a Plone 5.0.2 site: in portal_setup, Upgrades, select Products.CMFPlone:plone, and run the to502 upgrade profile.\n- Go to @@plone-upgrade, optionally select dry-run, and run the upgrade.\n\nResult: it will show as plain text.\nBTW, afterwards, all is fine: the migration has succeeded and it looks like all pages show up fine.\n\nAny idea?\n\n", "before_files": [{"content": "from plone.registry.interfaces import IRegistry\nfrom zope.component import queryUtility\n\nfrom ..browser.combine import combine_bundles\n\n\ndef combine(context):\n\n    logger = context.getLogger('bundles')\n    registry = queryUtility(IRegistry)\n\n    if registry is None:\n        logger.info(\"Cannot find registry\")\n        return\n\n    body = context.readDataFile('registry.xml')\n    if body and \"IBundleRegistry\" in body:\n        site = context.getSite()\n        combine_bundles(site)\n", "path": "Products/CMFPlone/resources/exportimport/bundles.py"}]}