mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Make URL columns 8000 characters wide
According to RFC 7230, URLs can be up too 8000 characters long. Resize all URL fields accordingly. Also, add a test to verify that URLs with more than 8000 characters are rejected by the update hook. Reported-by: Andreas Linz <klingt.net@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
0dce4c4bca
commit
1492444ecb
4 changed files with 33 additions and 4 deletions
|
@ -324,8 +324,9 @@ def main():
|
||||||
die_commit('invalid package name: {:s}'.format(
|
die_commit('invalid package name: {:s}'.format(
|
||||||
pkginfo['pkgname']), str(commit.id))
|
pkginfo['pkgname']), str(commit.id))
|
||||||
|
|
||||||
for field in ('pkgname', 'pkgdesc', 'url'):
|
max_len = {'pkgname': 255, 'pkgdesc': 255, 'url': 8000}
|
||||||
if field in pkginfo and len(pkginfo[field]) > 255:
|
for field in max_len.keys():
|
||||||
|
if field in pkginfo and len(pkginfo[field]) > max_len[field]:
|
||||||
die_commit('{:s} field too long: {:s}'.format(field,
|
die_commit('{:s} field too long: {:s}'.format(field,
|
||||||
pkginfo[field]), str(commit.id))
|
pkginfo[field]), str(commit.id))
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ CREATE TABLE Packages (
|
||||||
Name VARCHAR(255) NOT NULL,
|
Name VARCHAR(255) NOT NULL,
|
||||||
Version VARCHAR(255) NOT NULL DEFAULT '',
|
Version VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
Description VARCHAR(255) NULL DEFAULT NULL,
|
Description VARCHAR(255) NULL DEFAULT NULL,
|
||||||
URL VARCHAR(255) NULL DEFAULT NULL,
|
URL VARCHAR(8000) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
UNIQUE (Name),
|
UNIQUE (Name),
|
||||||
FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE
|
FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE
|
||||||
|
@ -227,7 +227,7 @@ CREATE INDEX RelationsRelName ON PackageRelations (RelName);
|
||||||
--
|
--
|
||||||
CREATE TABLE PackageSources (
|
CREATE TABLE PackageSources (
|
||||||
PackageID INTEGER UNSIGNED NOT NULL,
|
PackageID INTEGER UNSIGNED NOT NULL,
|
||||||
Source VARCHAR(255) NOT NULL DEFAULT "/dev/null",
|
Source VARCHAR(8000) NOT NULL DEFAULT "/dev/null",
|
||||||
SourceArch VARCHAR(255) NULL DEFAULT NULL,
|
SourceArch VARCHAR(255) NULL DEFAULT NULL,
|
||||||
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE
|
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE
|
||||||
) ENGINE = InnoDB;
|
) ENGINE = InnoDB;
|
||||||
|
|
|
@ -309,6 +309,22 @@ test_expect_success 'Pushing .SRCINFO with invalid epoch.' '
|
||||||
grep -q "^error: invalid epoch: !$" actual
|
grep -q "^error: invalid epoch: !$" actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'Pushing .SRCINFO with too long URL.' '
|
||||||
|
old=$(git -C aur.git rev-parse HEAD) &&
|
||||||
|
url="http://$(printf "%7993s" x | sed "s/ /x/g")/" &&
|
||||||
|
test_when_finished "git -C aur.git reset --hard $old" &&
|
||||||
|
(
|
||||||
|
cd aur.git &&
|
||||||
|
sed "s#.*url.*#\\0\\nurl = $url#" .SRCINFO >.SRCINFO.new
|
||||||
|
mv .SRCINFO.new .SRCINFO
|
||||||
|
git commit -q -am "Change URL"
|
||||||
|
) &&
|
||||||
|
new=$(git -C aur.git rev-parse HEAD) &&
|
||||||
|
AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
|
||||||
|
test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 &&
|
||||||
|
grep -q "^error: url field too long: $url\$" actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'Missing install file.' '
|
test_expect_success 'Missing install file.' '
|
||||||
old=$(git -C aur.git rev-parse HEAD) &&
|
old=$(git -C aur.git rev-parse HEAD) &&
|
||||||
test_when_finished "git -C aur.git reset --hard $old" &&
|
test_when_finished "git -C aur.git reset --hard $old" &&
|
||||||
|
|
12
upgrading/4.4.0.txt
Normal file
12
upgrading/4.4.0.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
1. Resize the URL column of the Packages table:
|
||||||
|
|
||||||
|
----
|
||||||
|
ALTER TABLE Packages MODIFY URL VARCHAR(8000) NULL DEFAULT NULL;
|
||||||
|
----
|
||||||
|
|
||||||
|
2. Resize the Source column of the PackageSources table:
|
||||||
|
|
||||||
|
----
|
||||||
|
ALTER TABLE PackageSources
|
||||||
|
MODIFY Source VARCHAR(8000) NOT NULL DEFAULT "/dev/null";
|
||||||
|
----
|
Loading…
Add table
Reference in a new issue