internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pallets/werkzeug

Issue:
Misleading documentation of authorization types
As I have learned from reading https://github.com/pallets/werkzeug/pull/2619#issue-1619078262, the new `Authorization` class has a `type` property. To find out if the desired auth scheme is used and, in my case, a Bearer token is given, this seems to be the new way as of Werkzeug 2.3.0:

```py
from flask import request

if request.authorization and request.authorization.type == "bearer":
    print(f"This is the Bearer token: {request.authorization.token}")
```

What's important here is that the value of `request.authorization.type` always is lowercase (due to `.lower()` being applied in the implementation).

The actual issue I see is that the docs however state:

> The authorization scheme, like `Basic`, `Digest`, or `Bearer`.

Thus, I suggest to replace those with actually possible examples, i.e. `basic`, `digest`, and `bearer`.

This applies to both the `Authorization` and `WWWAuthenticate` data structures.


Discussion:

Resolving patch:
diff --git a/src/werkzeug/datastructures/auth.py b/src/werkzeug/datastructures/auth.py
--- a/src/werkzeug/datastructures/auth.py
+++ b/src/werkzeug/datastructures/auth.py
@@ -50,14 +50,14 @@ def __init__(
         token: str | None = None,
     ) -> None:
         self.type = auth_type
-        """The authorization scheme, like ``Basic``, ``Digest``, or ``Bearer``."""
+        """The authorization scheme, like ``basic``, ``digest``, or ``bearer``."""
 
         if data is None:
             data = {}
 
         self.parameters = data
         """A dict of parameters parsed from the header. Either this or :attr:`token`
-        will have a value for a give scheme.
+        will have a value for a given scheme.
         """
 
         self.token = token
@@ -222,7 +222,7 @@ def _trigger_on_update(self) -> None:
 
     @property
     def type(self) -> str:
-        """The authorization scheme, like ``Basic``, ``Digest``, or ``Bearer``."""
+        """The authorization scheme, like ``basic``, ``digest``, or ``bearer``."""
         return self._type
 
     @type.setter
@@ -233,7 +233,7 @@ def type(self, value: str) -> None:
     @property
     def parameters(self) -> dict[str, str]:
         """A dict of parameters for the header. Only one of this or :attr:`token` should
-        have a value for a give scheme.
+        have a value for a given scheme.
         """
         return self._parameters
 
@@ -247,7 +247,7 @@ def parameters(self, value: dict[str, str]) -> None:
     @property
     def token(self) -> str | None:
         """A dict of parameters for the header. Only one of this or :attr:`token` should
-        have a value for a give scheme.
+        have a value for a given scheme.
         """
         return self._token
 


Test patch:
Repository: pallets/werkzeug

Issue:
use scrypt by default
#2654 added scrypt support, but couldn't make it the default because [PyPy didn't support it at the time](https://foss.heptapod.net/pypy/pypy/-/issues/3921). Now PyPy has fixed that and [made a release](https://doc.pypy.org/en/latest/release-v7.3.12.html), I'm comfortable with making scrypt the default.


Discussion:

Resolving patch:
diff --git a/src/werkzeug/security.py b/src/werkzeug/security.py
--- a/src/werkzeug/security.py
+++ b/src/werkzeug/security.py
@@ -67,17 +67,16 @@ def _hash_internal(method: str, salt: str, password: str) -> tuple[str, str]:
 
 
 def generate_password_hash(
-    password: str, method: str = "pbkdf2", salt_length: int = 16
+    password: str, method: str = "scrypt", salt_length: int = 16
 ) -> str:
     """Securely hash a password for storage. A password can be compared to a stored hash
     using :func:`check_password_hash`.
 
     The following methods are supported:
 
-    -   ``scrypt``, more secure but not available on PyPy. The parameters are ``n``,
-        ``r``, and ``p``, the default is ``scrypt:32768:8:1``. See
-        :func:`hashlib.scrypt`.
-    -   ``pbkdf2``, the default. The parameters are ``hash_method`` and ``iterations``,
+    -   ``scrypt``, the default. The parameters are ``n``, ``r``, and ``p``, the default
+        is ``scrypt:32768:8:1``. See :func:`hashlib.scrypt`.
+    -   ``pbkdf2``, less secure. The parameters are ``hash_method`` and ``iterations``,
         the default is ``pbkdf2:sha256:600000``. See :func:`hashlib.pbkdf2_hmac`.
 
     Default parameters may be updated to reflect current guidelines, and methods may be


Test patch:
diff --git a/tests/test_security.py b/tests/test_security.py
--- a/tests/test_security.py
+++ b/tests/test_security.py
@@ -11,7 +11,7 @@
 
 def test_default_password_method():
     value = generate_password_hash("secret")
-    assert value.startswith("pbkdf2:")
+    assert value.startswith("scrypt:")
 
 
 @pytest.mark.xfail(
Repository: pallets/werkzeug

Issue:
deprecate `__version__`
The `__version__` attribute is an old pattern from early in Python packaging. Setuptools eventually made it easier to use the pattern by allowing reading the value from the attribute at build time, and some other build backends have done the same.

However, there's no reason to expose this directly in code anymore. It's usually easier to use feature detection (`hasattr`, `try/except`) instead. `importlib.metadata.version("werkzeug")` can be used to get the version at runtime in a standard way, if it's really needed.


Discussion:

Resolving patch:
diff --git a/src/werkzeug/__init__.py b/src/werkzeug/__init__.py
--- a/src/werkzeug/__init__.py
+++ b/src/werkzeug/__init__.py
@@ -1,6 +1,25 @@
+from __future__ import annotations
+
+import typing as t
+
 from .serving import run_simple as run_simple
 from .test import Client as Client
 from .wrappers import Request as Request
 from .wrappers import Response as Response
 
-__version__ = "3.0.0.dev"
+
+def __getattr__(name: str) -> t.Any:
+    if name == "__version__":
+        import importlib.metadata
+        import warnings
+
+        warnings.warn(
+            "The '__version__' attribute is deprecated and will be removed in"
+            " Werkzeug 3.1. Use feature detection or"
+            " 'importlib.metadata.version(\"werkzeug\")' instead.",
+            DeprecationWarning,
+            stacklevel=2,
+        )
+        return importlib.metadata.version("werkzeug")
+
+    raise AttributeError(name)
diff --git a/src/werkzeug/serving.py b/src/werkzeug/serving.py
--- a/src/werkzeug/serving.py
+++ b/src/werkzeug/serving.py
@@ -154,9 +154,7 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
 
     @property
     def server_version(self) -> str:  # type: ignore
-        from . import __version__
-
-        return f"Werkzeug/{__version__}"
+        return self.server._server_version
 
     def make_environ(self) -> WSGIEnvironment:
         request_url = urlsplit(self.path)
@@ -796,6 +794,10 @@ def __init__(
         else:
             self.ssl_context = None
 
+        import importlib.metadata
+
+        self._server_version = f"Werkzeug/{importlib.metadata.version('werkzeug')}"
+
     def log(self, type: str, message: str, *args: t.Any) -> None:
         _log(type, message, *args)
 


Test patch:
Repository: pallets/werkzeug

Issue:
`pyright` in strict mode errors when using `formparser.MultiPartParser.parse`
I have a file which includes code like:

```python
from werkzeug.formparser import MultiPartParser

parser = MultiPartParser()
fields, files = parser.parse(
    stream=io.BytesIO(b"foo"),
    boundary=boundary.encode("utf-8"),
    content_length=len(b"foo"),
 )
```

I have the following configuration in `pyproject.toml`:

```toml
[tool.pyright]
typeCheckingMode = "strict"
```

`pyright` reports:

```
error: Type of "fields" is partially unknown
    Type of "fields" is "MultiDict[Unknown, Unknown]" (reportUnknownVariableType)
```

Environment:

- Python version: 3.12
- Werkzeug version: 3.0.1



Discussion:

Resolving patch:
diff --git a/src/werkzeug/formparser.py b/src/werkzeug/formparser.py
--- a/src/werkzeug/formparser.py
+++ b/src/werkzeug/formparser.py
@@ -352,7 +352,7 @@ def start_file_streaming(
 
     def parse(
         self, stream: t.IO[bytes], boundary: bytes, content_length: int | None
-    ) -> tuple[MultiDict, MultiDict]:
+    ) -> tuple[MultiDict[str, str], MultiDict[str, FileStorage]]:
         current_part: Field | File
         container: t.IO[bytes] | list[bytes]
         _write: t.Callable[[bytes], t.Any]


Test patch:
Repository: pallets/werkzeug

Issue:
MultiDict does not handle None values
The following code will result in a `TypeError`:
```python
invalid_values = MultiDict([('a', 'x'), ('b', ''), ('d', None)])
print(invalid_values.get('a', type=int))  # None
print(invalid_values.get('b', type=int))  # None
print(invalid_values.get('c', type=int))  # None
print(invalid_values.get('d', type=int))  # TypeError
```
I think the expected behavior would be to return `None` as all other error cases do.

This happens because the following code only checks for `ValueError` and not other errors like `TypeError`:
https://github.com/pallets/werkzeug/blob/d3dd65a27388fbd39d146caacf2563639ba622f0/src/werkzeug/datastructures/structures.py#L81-L84


Discussion:
Handling `TypeError` along with `ValueError` there makes sense.

Resolving patch:
diff --git a/src/werkzeug/datastructures/structures.py b/src/werkzeug/datastructures/structures.py
--- a/src/werkzeug/datastructures/structures.py
+++ b/src/werkzeug/datastructures/structures.py
@@ -70,8 +70,12 @@ def get(self, key, default=None, type=None):
                         be looked up.  If not further specified `None` is
                         returned.
         :param type: A callable that is used to cast the value in the
-                     :class:`MultiDict`.  If a :exc:`ValueError` is raised
-                     by this callable the default value is returned.
+                     :class:`MultiDict`.  If a :exc:`ValueError` or a
+                     :exc:`TypeError` is raised by this callable the default
+                     value is returned.
+
+        .. versionchanged:: 3.0.2
+           Returns the default value on :exc:`TypeError`, too.
         """
         try:
             rv = self[key]
@@ -80,7 +84,7 @@ def get(self, key, default=None, type=None):
         if type is not None:
             try:
                 rv = type(rv)
-            except ValueError:
+            except (ValueError, TypeError):
                 rv = default
         return rv
 


Test patch:
diff --git a/tests/test_datastructures.py b/tests/test_datastructures.py
--- a/tests/test_datastructures.py
+++ b/tests/test_datastructures.py
@@ -550,8 +550,9 @@ def test_value_conversion(self):
         assert d.get("foo", type=int) == 1
 
     def test_return_default_when_conversion_is_not_possible(self):
-        d = self.storage_class(foo="bar")
+        d = self.storage_class(foo="bar", baz=None)
         assert d.get("foo", default=-1, type=int) == -1
+        assert d.get("baz", default=-1, type=int) == -1
 
     def test_propagate_exceptions_in_conversion(self):
         d = self.storage_class(foo="bar")
Repository: UTNkar/moore

Issue:
Confirmation e-mails are not sent
For some reason the confirmation e-mails are no longer being send.


Discussion:

Resolving patch:
diff --git a/website/members/signals.py b/website/members/signals.py
--- a/website/members/signals.py
+++ b/website/members/signals.py
@@ -12,6 +12,7 @@
 
 @receiver(unconfirmed_email_created, dispatch_uid='send_email_confirmation')
 def send_confirmation_email(sender, email, user=None, **kwargs):
+    user = user or sender
     if user is not None:
         context = {
             'email': email,


Test patch:
Repository: UTNkar/moore

Issue:
Login is per-subdomain



Discussion:

Resolving patch:
diff --git a/website/website/settings/production.py b/website/website/settings/production.py
--- a/website/website/settings/production.py
+++ b/website/website/settings/production.py
@@ -56,10 +56,11 @@
 
 LOGGING_CONFIG = None
 
-# TODO: HTTPS security
-# CSRF_COOKIE_SECURE = True
-#
-# SESSION_COOKIE_SECURE = True
+CSRF_COOKIE_SECURE = True
+
+SESSION_COOKIE_DOMAIN = '.utn.se'
+
+SESSION_COOKIE_SECURE = True
 
 # Membership API
 MEMBERSHIP_API_USER = 'moore'


Test patch:
Repository: UTNkar/moore

Issue:
Missing search template
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

### Prerequisites

* [X] Put an X between the brackets on this line if you have done all of the
following:
    * Reproduced the problem with clear cache.
    * (If running the application locally:) Made sure your running the newest version on the development branch
    * Checked that your issue isn't already filed: https://github.com/UTNkar/moore/issues

### Description

The current search is now really working. Although you can search, the results are ugly and very spotty. 

Goal: Evaluate the searchable fields within Project Moore and make a search template.

### Steps to Reproduce

1. Visit the home page
2. Search something
3. Be disappointed ☹️ 

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->


Discussion:

Resolving patch:
diff --git a/website/materialize/templatetags/materialize.py b/website/materialize/templatetags/materialize.py
--- a/website/materialize/templatetags/materialize.py
+++ b/website/materialize/templatetags/materialize.py
@@ -23,8 +23,7 @@ def render_field(template, field, prefix=None):
         'field': field,
         'prefix': prefix,
     }
-    html = t.render(c)
-    return html
+    return t.render(c)
 
 
 @register.simple_tag
@@ -36,3 +35,12 @@ def materialize_field(field, prefix=None):
         return render_field('materialize/form/input.html', field, prefix)
     else:
         return field.as_widget()
+
+
+@register.inclusion_tag('materialize/pagination.html')
+def materialize_pagination(page, url):
+    return {
+        'page': page,
+        'paginator': page.paginator,
+        'url': url,
+    }
diff --git a/website/search/views.py b/website/search/views.py
--- a/website/search/views.py
+++ b/website/search/views.py
@@ -22,7 +22,7 @@ def search(request):
         search_results = Page.objects.none()
 
     # Pagination
-    paginator = Paginator(search_results, 10)
+    paginator = Paginator(search_results, 25)
     try:
         search_results = paginator.page(page)
     except PageNotAnInteger:


Test patch:
Repository: UTNkar/moore

Issue:
Wrong translation
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

### Prerequisites

* [ ] Put an X between the brackets on this line if you have done all of the
following:
    * Reproduced the problem with clear cache.
    * (If running the application locally:) Made sure your running the newest version on the development branch
    * Checked that your issue isn't already filed: https://github.com/UTNkar/moore/issues

### Description

In the banner editing section it says "engelsk bannertext" on both descriptions, so I do not know which one is the english and which one is the swedish. 


### Steps to Reproduce

1. [First Step]
2. [Second Step]
3. [and so on...]

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->


Discussion:

Resolving patch:
diff --git a/website/home/models.py b/website/home/models.py
--- a/website/home/models.py
+++ b/website/home/models.py
@@ -121,7 +121,7 @@ class Banner(Orderable):
             FieldPanel('title_sv'),
         ]),
         FieldPanel('text_en'),
-        FieldPanel('text_en'),
+        FieldPanel('text_sv'),
         FieldPanel('link'),
         FieldRowPanel([
             FieldPanel('button_en'),


Test patch:
Repository: UTNkar/moore

Issue:
Menu Translations
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

### Description

Not all menu pages are using `translated_title` when being added to the menu.

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->



Discussion:

Resolving patch:
diff --git a/website/website/templatetags/site_tags.py b/website/website/templatetags/site_tags.py
--- a/website/website/templatetags/site_tags.py
+++ b/website/website/templatetags/site_tags.py
@@ -22,9 +22,24 @@ def menu_items(context, parent, calling_page=None, sidenav=False):
     menuitems = parent.get_children().live().in_menu()
     for menuitem in menuitems:
         menuitem.show_dropdown = has_menu_children(menuitem)
-        if hasattr(menuitem, 'recruitmentpage'):
+        # TODO: There has to be a better alternative!
+        if hasattr(menuitem, 'googleformindex'):
+            menuitem.translated_title = menuitem.googleformindex\
+                .translated_title
+        elif hasattr(menuitem, 'googleformpage'):
+            menuitem.translated_title = menuitem.googleformpage\
+                .translated_title
+        elif hasattr(menuitem, 'homepage'):
+            menuitem.translated_title = menuitem.homepage.translated_title
+        elif hasattr(menuitem, 'recruitmentpage'):
             menuitem.translated_title = menuitem.recruitmentpage\
                 .translated_title
+        elif hasattr(menuitem, 'newsindexpage'):
+            menuitem.translated_title = menuitem.newsindexpage.translated_title
+        elif hasattr(menuitem, 'newspage'):
+            menuitem.translated_title = menuitem.newspage.translated_title
+        elif hasattr(menuitem, 'webpage'):
+            menuitem.translated_title = menuitem.webpage.translated_title
         # We don't directly check if calling_page is None since the template
         # engine can pass an empty string to calling_page
         # if the variable passed as calling_page does not exist.


Test patch:
Repository: UTNkar/moore

Issue:
Paragraph block alignment
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

See image:

![image](https://user-images.githubusercontent.com/29704138/27686692-2cadaf20-5cd4-11e7-92bf-caa849baa276.png)

[Description of the issue]

### Steps to Reproduce

1. [First Step]
2. [Second Step]
3. [and so on...]

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->



Discussion:
Probably just needs a container

Resolving patch:
diff --git a/website/blocks/models.py b/website/blocks/models.py
--- a/website/blocks/models.py
+++ b/website/blocks/models.py
@@ -89,7 +89,7 @@ class Meta:
 
 WAGTAIL_STATIC_BLOCKTYPES = [
     ('heading', HeadingBlock()),
-    ('paragraph', blocks.RichTextBlock()),
+    ('paragraph', blocks.RichTextBlock(template='blocks/paragraph.html')),
     ('image_description', ImageIconsBlock()),
     ('image_icons', ImageDescriptionBlock()),
     ('overlay', OverlayBlock()),


Test patch:
Repository: UTNkar/moore

Issue:
Menu Translations
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

### Description

Not all menu pages are using `translated_title` when being added to the menu.

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->



Discussion:
Not yet fixed for sub-pages

Resolving patch:
diff --git a/website/website/templatetags/site_tags.py b/website/website/templatetags/site_tags.py
--- a/website/website/templatetags/site_tags.py
+++ b/website/website/templatetags/site_tags.py
@@ -20,26 +20,9 @@ def has_menu_children(page):
 @register.inclusion_tag('tags/menu.html', takes_context=True)
 def menu_items(context, parent, calling_page=None, sidenav=False):
     menuitems = parent.get_children().live().in_menu()
+    menuitems = [m.specific for m in menuitems]
     for menuitem in menuitems:
         menuitem.show_dropdown = has_menu_children(menuitem)
-        # TODO: There has to be a better alternative!
-        if hasattr(menuitem, 'googleformindex'):
-            menuitem.translated_title = menuitem.googleformindex\
-                .translated_title
-        elif hasattr(menuitem, 'googleformpage'):
-            menuitem.translated_title = menuitem.googleformpage\
-                .translated_title
-        elif hasattr(menuitem, 'homepage'):
-            menuitem.translated_title = menuitem.homepage.translated_title
-        elif hasattr(menuitem, 'recruitmentpage'):
-            menuitem.translated_title = menuitem.recruitmentpage\
-                .translated_title
-        elif hasattr(menuitem, 'newsindexpage'):
-            menuitem.translated_title = menuitem.newsindexpage.translated_title
-        elif hasattr(menuitem, 'newspage'):
-            menuitem.translated_title = menuitem.newspage.translated_title
-        elif hasattr(menuitem, 'webpage'):
-            menuitem.translated_title = menuitem.webpage.translated_title
         # We don't directly check if calling_page is None since the template
         # engine can pass an empty string to calling_page
         # if the variable passed as calling_page does not exist.
@@ -57,8 +40,8 @@ def menu_items(context, parent, calling_page=None, sidenav=False):
 # Retrieves the children of the top menu items for the drop downs
 @register.inclusion_tag('tags/menu_children.html', takes_context=True)
 def menu_children(context, parent, sidenav=False):
-    children = parent.get_children()
-    children = children.live().in_menu()
+    children = parent.get_children().live().in_menu()
+    children = [c.specific for c in children]
     return {
         'parent': parent,
         'children': children,


Test patch:
Repository: UTNkar/moore

Issue:
Centre drive embeds
<!-- Do you want to ask a question? Are you looking for support? The system administrator can help you: admin@utn.se -->

### Description

Center drive embeds. Currently it looks a bit weird.

![image](https://user-images.githubusercontent.com/29704138/28264214-3dd2eb48-6aea-11e7-9944-fb199c8d4ecc.png)


### Steps to Reproduce

1. [First Step]
2. [Second Step]
3. [and so on...]

<!-- Please select the appropriate "topic category"/blue and "issue type"/yellow label -->



Discussion:

Resolving patch:
diff --git a/src/google/models.py b/src/google/models.py
--- a/src/google/models.py
+++ b/src/google/models.py
@@ -21,7 +21,7 @@ class Meta:
         label = _('Google Form')
         icon = 'fa-check-square-o'
         template = 'google/blocks/form.html'
-        group = _('Meta')
+        group = _('Embed')
 
 
 class GoogleFormIndex(Page):
@@ -124,3 +124,4 @@ class Meta:
         label = _('Google Drive')
         icon = 'fa-folder-open'
         template = 'google/blocks/drive.html'
+        group = _('Embed')


Test patch: