[aur-dev] [PATCH] pkgsubmit: count actual subdirectories
Dave Reisner
d at falconindy.com
Sun Mar 18 10:48:35 EDT 2012
On Sun, Mar 18, 2012 at 01:01:59PM +0100, Lukas Fleischer wrote:
> On Sat, Mar 17, 2012 at 10:35:49PM -0400, Dave Reisner wrote:
> > Rather than relying on a regex, detect directories in the uploaded
> > tarball and count the slashes. This avoids problems with bsdtar
> > inserting PaxHeader attributes into the archive which look something
> > like the following to Archive_Tar:
> >
> > PaxHeader/xcursor-protozoa
> > xcursor-protozoa/
> > xcursor-protozoa/PaxHeader/PKGBUILD
> > xcursor-protozoa/PKGBUILD
> >
> > This only occurs on certain filesystems (e.g. jfs), but the tarball is
> > by no means invalid. When extracted, it will only contain the PKGBUILD
> > within a single subdirectory.
> >
> > Signed-off-by: Dave Reisner <dreisner at archlinux.org>
> > ---
> > web/html/pkgsubmit.php | 9 +++------
> > 1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
> > index 75a4b69..5f5ba30 100644
> > --- a/web/html/pkgsubmit.php
> > +++ b/web/html/pkgsubmit.php
> > @@ -63,16 +63,13 @@ if ($uid):
> >
> > # Extract PKGBUILD into a string
> > $pkgbuild_raw = '';
> > - $dircount = 0;
> > foreach ($tar->listContent() as $tar_file) {
> > if (preg_match('/^[^\/]+\/PKGBUILD$/', $tar_file['filename'])) {
> > $pkgbuild_raw = $tar->extractInString($tar_file['filename']);
> > }
> > - elseif (preg_match('/^[^\/]+\/$/', $tar_file['filename'])) {
> > - if (++$dircount > 1) {
> > - $error = __("Error - source tarball may not contain more than one directory.");
> > - break;
> > - }
> > + elseif ($tar_file['filetype'] == 5 && count(explode(',', $tar_file['filename'])) > 1) {
>
> We don't check for nested subdirectories here, that is done further
> below (check the last elseif-block). I also doubt that this one is the
> check that fails since we count the entries that have a trailing "/"
> here and, looking at the listing in your commit message, there don't
> seem to be more than one of these. You should probably change the logic
> in the last elseif condition instead of here...
>
> Also, the "," delimiter in explode() seems a bit wrong? :)
Epic failure. I think I divided by 0 before sending this patch.
d
> > + $error = __("Error - source tarball may not contain more than one directory.");
> > + break;
> > }
> > elseif (preg_match('/^[^\/]+$/', $tar_file['filename'])) {
> > $error = __("Error - source tarball may not contain files outside a directory.");
> > --
> > 1.7.9.4
More information about the aur-dev
mailing list