prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  rich_text: tel schema
  When providing email links using the mailto schema in richtext description like `[Email us!](mailto:mail@weandus.com)`, resulting in [Email us!](mailto:mail@weandus.com), Pretix creates the correct `<a>` tag. However, users also use their mobile phone. It would be awesome to also be able to use the `tel` schema like `[Call us!](tel:+1-202-555-0102)`. At the moment, pretix just creates an `<a>` tag without an `href`, so the Telephone app is not opened.
  rich_text: tel schema
  When providing email links using the mailto schema in richtext description like `[Email us!](mailto:mail@weandus.com)`, resulting in [Email us!](mailto:mail@weandus.com), Pretix creates the correct `<a>` tag. However, users also use their mobile phone. It would be awesome to also be able to use the `tel` schema like `[Call us!](tel:+1-202-555-0102)`. At the moment, pretix just creates an `<a>` tag without an `href`, so the Telephone app is not opened.
  
  </issue>
  <code>
  [start of src/pretix/base/templatetags/rich_text.py]
  1 import urllib.parse
  2 
  3 import bleach
  4 import markdown
  5 from bleach import DEFAULT_CALLBACKS
  6 from django import template
  7 from django.conf import settings
  8 from django.core import signing
  9 from django.urls import reverse
  10 from django.utils.http import is_safe_url
  11 from django.utils.safestring import mark_safe
  12 
  13 register = template.Library()
  14 
  15 ALLOWED_TAGS = [
  16     'a',
  17     'abbr',
  18     'acronym',
  19     'b',
  20     'blockquote',
  21     'br',
  22     'code',
  23     'em',
  24     'i',
  25     'li',
  26     'ol',
  27     'strong',
  28     'ul',
  29     'p',
  30     'table',
  31     'tbody',
  32     'thead',
  33     'tr',
  34     'td',
  35     'th',
  36     'div',
  37     'span',
  38     'hr',
  39     'h1',
  40     'h2',
  41     'h3',
  42     'h4',
  43     'h5',
  44     'h6',
  45     'pre',
  46     # Update doc/user/markdown.rst if you change this!
  47 ]
  48 
  49 ALLOWED_ATTRIBUTES = {
  50     'a': ['href', 'title'],
  51     'abbr': ['title'],
  52     'acronym': ['title'],
  53     'table': ['width'],
  54     'td': ['width', 'align'],
  55     'div': ['class'],
  56     'p': ['class'],
  57     'span': ['class'],
  58     # Update doc/user/markdown.rst if you change this!
  59 }
  60 
  61 ALLOWED_PROTOCOLS = ['http', 'https', 'mailto', 'tel']
  62 
  63 
  64 def safelink_callback(attrs, new=False):
  65     url = attrs.get((None, 'href'), '/')
  66     if not is_safe_url(url) and not url.startswith('mailto:'):
  67         signer = signing.Signer(salt='safe-redirect')
  68         attrs[None, 'href'] = reverse('redirect') + '?url=' + urllib.parse.quote(signer.sign(url))
  69         attrs[None, 'target'] = '_blank'
  70         attrs[None, 'rel'] = 'noopener'
  71     return attrs
  72 
  73 
  74 def abslink_callback(attrs, new=False):
  75     attrs[None, 'href'] = urllib.parse.urljoin(settings.SITE_URL, attrs.get((None, 'href'), '/'))
  76     attrs[None, 'target'] = '_blank'
  77     attrs[None, 'rel'] = 'noopener'
  78     return attrs
  79 
  80 
  81 def markdown_compile(source):
  82     return bleach.clean(
  83         markdown.markdown(
  84             source,
  85             extensions=[
  86                 'markdown.extensions.sane_lists',
  87                 # 'markdown.extensions.nl2br',  # TODO: Enable, but check backwards-compatibility issues e.g. with mails
  88             ]
  89         ),
  90         tags=ALLOWED_TAGS,
  91         attributes=ALLOWED_ATTRIBUTES,
  92         protocols=ALLOWED_PROTOCOLS,
  93     )
  94 
  95 
  96 @register.filter
  97 def rich_text(text: str, **kwargs):
  98     """
  99     Processes markdown and cleans HTML in a text input.
  100     """
  101     text = str(text)
  102     body_md = bleach.linkify(
  103         markdown_compile(text),
  104         callbacks=DEFAULT_CALLBACKS + ([safelink_callback] if kwargs.get('safelinks', True) else [abslink_callback])
  105     )
  106     return mark_safe(body_md)
  107
  [end of src/pretix/base/templatetags/rich_text.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/src/pretix/base/templatetags/rich_text.py b/src/pretix/base/templatetags/rich_text.py
  --- a/src/pretix/base/templatetags/rich_text.py
  +++ b/src/pretix/base/templatetags/rich_text.py
  @@ -63,7 +63,7 @@
   
   def safelink_callback(attrs, new=False):
       url = attrs.get((None, 'href'), '/')
  -    if not is_safe_url(url) and not url.startswith('mailto:'):
  +    if not is_safe_url(url) and not url.startswith('mailto:') and not url.startswith('tel:'):
           signer = signing.Signer(salt='safe-redirect')
           attrs[None, 'href'] = reverse('redirect') + '?url=' + urllib.parse.quote(signer.sign(url))
           attrs[None, 'target'] = '_blank'
  
verification_info: {"golden_diff": "diff --git a/src/pretix/base/templatetags/rich_text.py b/src/pretix/base/templatetags/rich_text.py\n--- a/src/pretix/base/templatetags/rich_text.py\n+++ b/src/pretix/base/templatetags/rich_text.py\n@@ -63,7 +63,7 @@\n \n def safelink_callback(attrs, new=False):\n     url = attrs.get((None, 'href'), '/')\n-    if not is_safe_url(url) and not url.startswith('mailto:'):\n+    if not is_safe_url(url) and not url.startswith('mailto:') and not url.startswith('tel:'):\n         signer = signing.Signer(salt='safe-redirect')\n         attrs[None, 'href'] = reverse('redirect') + '?url=' + urllib.parse.quote(signer.sign(url))\n         attrs[None, 'target'] = '_blank'\n", "issue": "rich_text: tel schema\nWhen providing email links using the mailto schema in richtext description like `[Email us!](mailto:mail@weandus.com)`, resulting in [Email us!](mailto:mail@weandus.com), Pretix creates the correct `<a>` tag. However, users also use their mobile phone. It would be awesome to also be able to use the `tel` schema like `[Call us!](tel:+1-202-555-0102)`. At the moment, pretix just creates an `<a>` tag without an `href`, so the Telephone app is not opened.\nrich_text: tel schema\nWhen providing email links using the mailto schema in richtext description like `[Email us!](mailto:mail@weandus.com)`, resulting in [Email us!](mailto:mail@weandus.com), Pretix creates the correct `<a>` tag. However, users also use their mobile phone. It would be awesome to also be able to use the `tel` schema like `[Call us!](tel:+1-202-555-0102)`. At the moment, pretix just creates an `<a>` tag without an `href`, so the Telephone app is not opened.\n", "before_files": [{"content": "import urllib.parse\n\nimport bleach\nimport markdown\nfrom bleach import DEFAULT_CALLBACKS\nfrom django import template\nfrom django.conf import settings\nfrom django.core import signing\nfrom django.urls import reverse\nfrom django.utils.http import is_safe_url\nfrom django.utils.safestring import mark_safe\n\nregister = template.Library()\n\nALLOWED_TAGS = [\n    'a',\n    'abbr',\n    'acronym',\n    'b',\n    'blockquote',\n    'br',\n    'code',\n    'em',\n    'i',\n    'li',\n    'ol',\n    'strong',\n    'ul',\n    'p',\n    'table',\n    'tbody',\n    'thead',\n    'tr',\n    'td',\n    'th',\n    'div',\n    'span',\n    'hr',\n    'h1',\n    'h2',\n    'h3',\n    'h4',\n    'h5',\n    'h6',\n    'pre',\n    # Update doc/user/markdown.rst if you change this!\n]\n\nALLOWED_ATTRIBUTES = {\n    'a': ['href', 'title'],\n    'abbr': ['title'],\n    'acronym': ['title'],\n    'table': ['width'],\n    'td': ['width', 'align'],\n    'div': ['class'],\n    'p': ['class'],\n    'span': ['class'],\n    # Update doc/user/markdown.rst if you change this!\n}\n\nALLOWED_PROTOCOLS = ['http', 'https', 'mailto', 'tel']\n\n\ndef safelink_callback(attrs, new=False):\n    url = attrs.get((None, 'href'), '/')\n    if not is_safe_url(url) and not url.startswith('mailto:'):\n        signer = signing.Signer(salt='safe-redirect')\n        attrs[None, 'href'] = reverse('redirect') + '?url=' + urllib.parse.quote(signer.sign(url))\n        attrs[None, 'target'] = '_blank'\n        attrs[None, 'rel'] = 'noopener'\n    return attrs\n\n\ndef abslink_callback(attrs, new=False):\n    attrs[None, 'href'] = urllib.parse.urljoin(settings.SITE_URL, attrs.get((None, 'href'), '/'))\n    attrs[None, 'target'] = '_blank'\n    attrs[None, 'rel'] = 'noopener'\n    return attrs\n\n\ndef markdown_compile(source):\n    return bleach.clean(\n        markdown.markdown(\n            source,\n            extensions=[\n                'markdown.extensions.sane_lists',\n                # 'markdown.extensions.nl2br',  # TODO: Enable, but check backwards-compatibility issues e.g. with mails\n            ]\n        ),\n        tags=ALLOWED_TAGS,\n        attributes=ALLOWED_ATTRIBUTES,\n        protocols=ALLOWED_PROTOCOLS,\n    )\n\n\n@register.filter\ndef rich_text(text: str, **kwargs):\n    \"\"\"\n    Processes markdown and cleans HTML in a text input.\n    \"\"\"\n    text = str(text)\n    body_md = bleach.linkify(\n        markdown_compile(text),\n        callbacks=DEFAULT_CALLBACKS + ([safelink_callback] if kwargs.get('safelinks', True) else [abslink_callback])\n    )\n    return mark_safe(body_md)\n", "path": "src/pretix/base/templatetags/rich_text.py"}]}