gnome-games r8911 - trunk/gnome-sudoku/src/lib
- From: thomashpa svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8911 - trunk/gnome-sudoku/src/lib
- Date: Sat, 28 Mar 2009 02:05:39 +0000 (UTC)
Author: thomashpa
Date: Sat Mar 28 02:05:39 2009
New Revision: 8911
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8911&view=rev
Log:
Don't crash on malformed save file. Fixes bug #516491
Modified:
trunk/gnome-sudoku/src/lib/saver.py
Modified: trunk/gnome-sudoku/src/lib/saver.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/saver.py (original)
+++ trunk/gnome-sudoku/src/lib/saver.py Sat Mar 28 02:05:39 2009
@@ -211,8 +211,22 @@
except:
print 'Warning: could not read file',f
else:
- jar['saved_at']=os.stat(f)[8]
- games.append(jar)
+ if self.is_valid(jar):
+ jar['saved_at']=os.stat(f)[8]
+ games.append(jar)
+ else:
+ print 'Warning: malformed save game',f
return games
-
+
+ def is_valid (self, jar):
+ virgin = jar['game'].split('\n')[0].replace(' ','')
+ played = jar['game'].split('\n')[1].replace(' ','')
+
+ if len(virgin) != 81 or len(played) != 81:
+ return False
+
+ if not virgin.isdigit() or not played.isdigit():
+ return False
+
+ return True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]