Skip to content
Snippets Groups Projects

fix regular expression used for matching RCS keywords

  1. Jan 06, 2023
    • Stefan Sperling's avatar
      fix regular expression used for matching RCS keywords · 20386554
      Stefan Sperling authored
      The function RcsKeywords.expand_keyword() uses a regular expression
      to detect keywords in lines of a file. This expression treated the
      closing $-sign of the keyword as optional. This fails when a line
      contains an invalid keyword declaration which lacks the trailing
      $-sign, followed by a valid keyword declaration.
      
      For example, consider this line from a file in the ccvs CVS repository:
      
        #ident	"@(#)cvs/contrib/pcl-cvs:$Name:  $Id$"
      
      Here, the CVS server expands the $Id$ keyword, and it does not expand
      the $Name$ keyword (which lacks a trailing $-sign).
      
      Our regular expression would split this line into two match groups:
      
        1: #ident	"@(#)cvs/contrib/pcl-cvs:$Name:  $
        2: Id$
      
      Neither match produces a valid keyword and hence expand_keyword()
      would not expand keywords on this line.
      
      Tweak our test data to cover the above example, and fix the regular
      expression such that the trailing $-sign is required. With this change
      in place we match the $Id$ part of the above example and expand keywords
      on this line just like the CVS server does.
      20386554
Loading