File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -71,14 +71,22 @@ public void dirtyDBHealthCheck() {
7171 try {
7272 List <String > s = Files .readAllLines (this .dirtyDB .toPath ());
7373 String l ;
74- if (s .size () == 0 || (l = s .get (s .size () - 1 )).length () == 0 || l . charAt ( 0 ) == '{' ) return ;
74+ if (s .size () == 0 || (l = s .get (s .size () - 1 )).length () == 0 || dirtyDBLineOK ( l ) ) return ;
7575 // start healing
76- while (s .size () > 0 && (l = s .get (s .size () - 1 )).length () > 0 && l . charAt ( 0 ) != '{' ) s .remove (s .size () - 1 );
76+ while (s .size () > 0 && (l = s .get (s .size () - 1 )).length () > 0 && ! dirtyDBLineOK ( l ) ) s .remove (s .size () - 1 );
7777 Files .write (this .dirtyDB .toPath (), s );
7878 } catch (IOException e ) {
7979 e .printStackTrace ();
8080 }
8181 }
82+
83+ private boolean dirtyDBLineOK (String line ) {
84+ assert line != null && line .length () > 0 ;
85+ if (line .charAt (0 ) != '{' ) return false ;
86+ if (line .charAt (line .length () - 1 ) != '}' ) return false ;
87+ // we could do a json parsing here to further prove that the line is ok, but maybe that is not necessary
88+ return true ;
89+ }
8290
8391 /**
8492 * check if this etherpad is private. A etherpad is private if it is running at localhost
You can’t perform that action at this time.
0 commit comments