cvs-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cvs-cvs] ccvs/src ChangeLog rcs.c sanity.sh


From: Jim Hyslop
Subject: [Cvs-cvs] ccvs/src ChangeLog rcs.c sanity.sh
Date: Sat, 24 Jun 2006 03:05:11 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Jim Hyslop <jhyslop>    06/06/24 03:05:10

Modified files:
        src            : ChangeLog rcs.c sanity.sh 

Log message:
                * rcs.c: Tighten up error checking on valid tag identifiers.
                * sanity.sh: added test to exercise tag error checking.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3456&r2=1.3457
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/rcs.c?cvsroot=cvs&r1=1.373&r2=1.374
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/sanity.sh?cvsroot=cvs&r1=1.1157&r2=1.1158

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3456
retrieving revision 1.3457
diff -u -b -r1.3456 -r1.3457
--- ChangeLog   24 Jun 2006 02:19:19 -0000      1.3456
+++ ChangeLog   24 Jun 2006 03:05:10 -0000      1.3457
@@ -1,5 +1,8 @@
 2006-06-24  Jim Hyslop <address@hidden>
 
+       * rcs.c: Tighten up error checking on valid tag identifiers.
+       * sanity.sh: added test to exercise tag error checking.
+
        * sign.c, verify.c: back out "b" changes made earlier today - not
        supported by popen on other platforms.
 

Index: rcs.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/rcs.c,v
retrieving revision 1.373
retrieving revision 1.374
diff -u -b -r1.373 -r1.374
--- rcs.c       21 Jun 2006 18:55:21 -0000      1.373
+++ rcs.c       24 Jun 2006 03:05:10 -0000      1.374
@@ -3373,30 +3373,23 @@
 
 
 /*
- * Do some consistency checks on the symbolic tag... These should equate
- * pretty close to what RCS checks, though I don't know for certain.
+ * Do some consistency checks on the symbolic tag... This is much stricter
+ * to what RCS checks: we allow letters, underscores, dashes and numbers.
+ * RCS allows a lot more characters.
  */
 void
 RCS_check_tag (const char *tag)
 {
-    char *invalid = "$,.:;@";          /* invalid RCS tag characters */
     const char *cp;
 
-    /*
-     * The first character must be an alphabetic letter. The remaining
-     * characters cannot be non-visible graphic characters, and must not be
-     * in the set of "invalid" RCS identifier characters.
-     */
+    /* The first character must be an alphabetic letter. */
     if (isalpha ((unsigned char) *tag))
     {
        for (cp = tag; *cp; cp++)
        {
-           if (!isgraph ((unsigned char) *cp))
-               error (1, 0, "tag `%s' has non-visible graphic characters",
-                      tag);
-           if (strchr (invalid, *cp))
-               error (1, 0, "tag `%s' must not contain the characters `%s'",
-                      tag, invalid);
+           if (!isalnum ((unsigned char) *cp) && *cp != '_' && *cp != '-' )
+               error (1, 0, "tag `%s' may contain only letters, numbers, "
+                       "_ and -", tag);
        }
     }
     else

Index: sanity.sh
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1157
retrieving revision 1.1158
diff -u -b -r1.1157 -r1.1158
--- sanity.sh   20 Jun 2006 17:46:02 -0000      1.1157
+++ sanity.sh   24 Jun 2006 03:05:10 -0000      1.1158
@@ -2068,7 +2068,7 @@
        tests="${tests} rdiff2 diff diffnl death death2 death-rtag"
        tests="${tests} rm-update-message rmadd rmadd2 rmadd3 resurrection"
        tests="${tests} dirs dirs2 branches branches2 branches3"
-       tests="${tests} branches4 tagc tagf tag-space"
+       tests="${tests} branches4 tagc tagf tag-space tag-valid"
        tests="${tests} rcslib multibranch import importb importc importX"
        tests="$tests importX2 import-CVS import-quirks"
        tests="${tests} update-p import-after-initial branch-after-import"
@@ -8900,6 +8900,74 @@
          ;;
 
 
+       # Test for valid characters in tags
+       tag-valid)
+         # Setup; check in first-dir/file1
+         mkdir 1; cd 1
+         dotest tag-valid-init-1 "$testcvs -q co -l ."
+         mkdir first-dir
+         $testcvs add first-dir 1>/dev/null 2>/dev/null
+         cd first-dir
+         touch file1
+         $testcvs add file1 1>/dev/null 2>/dev/null
+         $testcvs -Q ci -m add 1>/dev/null
+         dotest tag-valid-1 "$testcvs -Q tag abcdefghijklmnopqrstuvwxyz"
+         dotest tag-valid-2 "$testcvs -Q tag ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+         dotest tag-valid-3 "$testcvs -Q tag a0123456789-_"
+
+         dotest_fail tag-valid-4 "$testcvs -Q tag _a" \
+"${SPROG} \[tag aborted\]: tag \`_a' must start with a letter"
+
+      dotest_fail tag-valid-5 "$testcvs -Q tag a$" \
+"$SPROG \[tag aborted\]: tag \`a$' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-6 "$testcvs -Q tag a." \
+"$SPROG \[tag aborted\]: tag \`a\.' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-7 "$testcvs -Q tag a:" \
+"$SPROG \[tag aborted\]: tag \`a:' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-8 "$testcvs -Q tag a," \
+"$SPROG \[tag aborted\]: tag \`a,' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-9 "$testcvs -Q tag a\;" \
+"$SPROG \[tag aborted\]: tag \`a;' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-10 "$testcvs -Q tag a@" \
+"$SPROG \[tag aborted\]: tag \`a@' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-12 "$testcvs -Q tag a/" \
+"$SPROG \[tag aborted\]: tag \`a/' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-13 "$testcvs -Q tag a!" \
+"$SPROG \[tag aborted\]: tag \`a!' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-14 "$testcvs -Q tag a#" \
+"$SPROG \[tag aborted\]: tag \`a#' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-15 "$testcvs -Q tag a%" \
+"$SPROG \[tag aborted\]: tag \`a%' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-16 "$testcvs -Q tag a^" \
+"$SPROG \[tag aborted\]: tag \`a^' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-17 "$testcvs -Q tag a\(" \
+"$SPROG \[tag aborted\]: tag \`a(' may contain only letters, numbers, _ and -"
+
+      dotest_fail tag-valid-18 "$testcvs -Q tag a\)" \
+"$SPROG \[tag aborted\]: tag \`a)' may contain only letters, numbers, _ and -"
+
+      if $keep; then
+        echo Keeping $TESTDIR and exiting due to --keep
+        exit 0
+      fi
+
+      cd ../..
+      rm -r 1
+      modify_repo rm -rf $CVSROOT_DIRNAME/first-dir
+
+
+      ;;
 
        rcslib)
          # Test librarification of RCS.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]