Projet

Général

Profil

0001-sql-check-id-parameter-passed-to-.get-method-42827.patch

Frédéric Péters, 13 mai 2020 13:23

Télécharger (1,48 ko)

Voir les différences:

Subject: [PATCH] sql: check id parameter passed to .get() method (#42827)

 wcs/sql.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
wcs/sql.py
1095 1095
    @classmethod
1096 1096
    @guard_postgres
1097 1097
    def get(cls, id, ignore_errors=False, ignore_migration=False):
1098
        if id is None:
1099
            if ignore_errors:
1098
        try:
1099
            int(id)
1100
        except (TypeError, ValueError):
1101
            if ignore_errors and id is None:
1100 1102
                return None
1101 1103
            else:
1102 1104
                raise KeyError()
......
1658 1660
    @classmethod
1659 1661
    @guard_postgres
1660 1662
    def get(cls, id, ignore_errors=False, ignore_migration=False):
1661
        if id is None:
1662
            if ignore_errors:
1663
        try:
1664
            int(id)
1665
        except (TypeError, ValueError):
1666
            if ignore_errors and id is None:
1663 1667
                return None
1664 1668
            else:
1665 1669
                raise KeyError()
1666
        else:
1667
            try:
1668
                int(id)
1669
            except ValueError:
1670
                raise KeyError()
1671 1670
        conn, cur = get_connection_and_cursor()
1672 1671

  
1673 1672
        fields = cls.get_data_fields()
1674
-