chiark / gitweb /
dgit: Regularise patch filenames, and defend against funny commit subjects
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 9 Jul 2017 13:45:17 +0000 (14:45 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 9 Jul 2017 15:25:53 +0000 (16:25 +0100)
* Do not specified patch names which look like series filenames
* When we invent a filename based on a commit message, add ".patch".

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm
debian/changelog
dgit
tests/tests/quilt

index ba1c28801aba0acb77fced48bb8966a878dc8973..dcecbd1a840e7f0c7718b398d585e2e4d4e3fe77 100644 (file)
@@ -50,7 +50,7 @@ BEGIN {
                      git_get_ref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
                       $package_re $component_re $deliberately_re
                      git_get_ref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
                       $package_re $component_re $deliberately_re
-                     $distro_re $versiontag_re
+                     $distro_re $versiontag_re $series_filename_re
                       $branchprefix
                       initdebug enabledebug enabledebuglevel
                       printdebug debugcmd
                       $branchprefix
                       initdebug enabledebug enabledebuglevel
                       printdebug debugcmd
@@ -69,6 +69,7 @@ our $deliberately_re = "(?:TEST-)?$package_re";
 our $distro_re = $component_re;
 our $versiontag_re = qr{[-+.\%_0-9a-zA-Z/]+};
 our $branchprefix = 'dgit';
 our $distro_re = $component_re;
 our $versiontag_re = qr{[-+.\%_0-9a-zA-Z/]+};
 our $branchprefix = 'dgit';
+our $series_filename_re = qr{(?:^|\.)series(?!\n)$}s;
 
 # policy hook exit status bits
 # see dgit-repos-server head comment for documentation
 
 # policy hook exit status bits
 # see dgit-repos-server head comment for documentation
index 5d78d25911eba202f980533ceb0f67bb6a471abf..7900c925d91e1cc3e8f0a45db2f335ba0ef5e47c 100644 (file)
@@ -2,6 +2,9 @@ dgit (3.12~) unstable; urgency=medium
 
   Important bugfixes to dgit:
   * Pass --no-renames to git diff-tree -z, avoiding potential trouble.
 
   Important bugfixes to dgit:
   * Pass --no-renames to git diff-tree -z, avoiding potential trouble.
+  * Defend against commit subject lines which would generate patches which
+    look like series files, etc.  Involves adding .patch to all generated
+    patch filenames.
 
  --
 
 
  --
 
diff --git a/dgit b/dgit
index 91172dad890a4e25442cc83e9fa832a426e64296..51975965deb49aad24c205848e0ca5170983185b 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -5274,6 +5274,7 @@ sub quiltify ($$$$) {
                die "contains unexpected slashes\n" if m{//} || m{/$};
                die "contains leading punctuation\n" if m{^\W} || m{/\W};
                die "contains bad character(s)\n" if m{[^-a-z0-9_.+=~/]}i;
                die "contains unexpected slashes\n" if m{//} || m{/$};
                die "contains leading punctuation\n" if m{^\W} || m{/\W};
                die "contains bad character(s)\n" if m{[^-a-z0-9_.+=~/]}i;
+               die "is series file\n" if m{$series_filename_re}o;
                die "too long" if length > 200;
            };
            return $_ unless $@;
                die "too long" if length > 200;
            };
            return $_ unless $@;
@@ -5312,6 +5313,7 @@ sub quiltify ($$$$) {
            $patchname =~ y/-a-z0-9_.+=~//cd;
            $patchname =~ s/^\W/x-$&/;
            $patchname = substr($patchname,0,40);
            $patchname =~ y/-a-z0-9_.+=~//cd;
            $patchname =~ s/^\W/x-$&/;
            $patchname = substr($patchname,0,40);
+           $patchname .= ".patch";
        }
        if (!defined $patchdir) {
            $patchdir = '';
        }
        if (!defined $patchdir) {
            $patchdir = '';
index 1a921b3791a3f6716d001e1cc3f1dcf6f9bc0cf6..f26f74458a27dc9ce5c592b9aac94897df6d4284 100755 (executable)
@@ -41,8 +41,8 @@ iteration
 
 diff <<END - debian/patches/series
 ups-topic/ups-yml
 
 diff <<END - debian/patches/series
 ups-topic/ups-yml
-spongiform-upstream-new-file-incl-change
-zorkmid-options-=-42
+spongiform-upstream-new-file-incl-change.patch
+zorkmid-options-=-42.patch
 END
 
 for f in `cat debian/patches/series`; do
 END
 
 for f in `cat debian/patches/series`; do