Changeset - 74d5ae62bf74
[Not reviewed]
default
0 1 0
Mads Kiilerich - 10 years ago 2015-08-17 01:11:42
madski@unity3d.com
db: better handling of decoding of changeset_cache values from the database

Do some validation of the data to prevent that incorrect data cause weird
failures when they are used later on.
1 file changed with 5 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/model/db.py
Show inline comments
 
@@ -1051,14 +1051,12 @@ class Repository(Base, BaseModel):
 

	
 
    @hybrid_property
 
    def changeset_cache(self):
 
        from kallithea.lib.vcs.backends.base import EmptyChangeset
 
        dummy = EmptyChangeset().__json__()
 
        if not self._changeset_cache:
 
            return dummy
 
        try:
 
            return json.loads(self._changeset_cache)
 
        except TypeError:
 
            return dummy
 
            cs_cache = json.loads(self._changeset_cache) # might raise on bad data
 
            cs_cache['raw_id'] # verify data, raise exception on error
 
            return cs_cache
 
        except (TypeError, KeyError, ValueError):
 
            return EmptyChangeset().__json__()
 

	
 
    @changeset_cache.setter
 
    def changeset_cache(self, val):
0 comments (0 inline, 0 general)