Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/rcsparser.tcl part of check-in [294156a36f] - Extended the RCS parser to handle extended (aka new) phrases coming after the regular data of a revision, in the revision tree. by aku on 2007-10-19 07:22:44. [view]

To:

File tools/cvs2fossil/lib/rcsparser.tcl part of check-in [1527954d87] - Added more checks to the RCS parser to detect bogus symbol names and problematic log messages. Added ability to rewind back to the beginning of the last recognized token for a nicer positioned error message. by aku on 2007-10-23 04:32:06. [view]

@@ -77,8 +77,12 @@
 
     proc Symbols {} {
 	RequiredLiteral symbols
 	while {[Ident -> symbol]} {
+	    if {![regexp {^\d*[^/,.:;@$]([^/,.:;@$]*\d*)*$} $symbol]} {
+		Rewind
+		Bad {symbol name}
+	    }
 	    RequiredNumber -> rev
 	    Call deftag $symbol $rev
 	}
 	Semicolon
@@ -216,8 +220,13 @@
     proc DeltaTexts {} {
 	while {[OptionalNumber -> rev]} {
 	    RequiredLiteral log
 	    RequiredString      -> cmsg
+	    if {[regexp {[\000-\010\013\014\016-\037]} $cmsg]} {
+		Rewind
+		Bad "log message for $rev contains at least one control character"
+	    }
+
 	    RequiredLiteral text
 	    RequiredStringRange -> delta
 	    Call extend $rev $cmsg $delta
 	}
@@ -386,17 +395,27 @@
 	# location.
 	upvar 1 $mv match
 	::variable mypos
 	::variable mysize
+	::variable mylastpos
 
 	struct::list assign $match s e
 	#puts "<$s $e> [info level -1]"
 
+	set  mylastpos $mypos
 	set  mypos $e
 	incr mypos
 
 	log progress 2 rcs $mypos $mysize
 	#puts $mypos/$mysize
+	return
+    }
+
+    proc Rewind {} {
+	::variable mypos
+	::variable mylastpos
+
+	set  mypos $mylastpos
 	return
     }
 
     proc Expected {x} {
@@ -404,8 +423,16 @@
 	::variable mypos
 	set e $mypos ; incr e 30
 	return -code error -errorcode vc::rcs::parser \
 	    "Expected $x @ '[string range $mydata $mypos $e]...'"
+    }
+
+    proc Bad {x} {
+	::variable mydata
+	::variable mypos
+	set e $mypos ; incr e 30
+	return -code error -errorcode vc::rcs::parser \
+	    "Bad $x @ '[string range $mydata $mypos $e]...'"
     }
 
     # # ## ### ##### ######## #############
     ## Setup, callbacks.