Commit graph

2243 commits

Author SHA1 Message Date
Eli Schwartz
243fb92273 Fix setting keywords in the SSH interface
This was broken in commit 8914a41db9 which
refactored the argument parsing. Instead of checking for at least the
set-keywords command and a pkgbase name, we were checking for *exactly*
the command and pkgbase name, leaving no room for keywords...

As a result, while we could clear the keywords, we could not set them.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-07-22 17:47:34 +02:00
Lukas Fleischer
ad4acfb9aa Document new git-serve commands
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-07-22 17:46:54 +02:00
Mark Weiman
0c6a415cb3 gendummydata.py: Fix NOT NULL constraint problems
PackageBases.FlaggerComment and PackageComments.RenderedComment cannot
be NULL and would cause problems in the output file for sqlite users.
This patch adds empty strings ("") as values for these fields.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-05-02 16:29:40 +02:00
Lukas Fleischer
a8ac2004d3 Add support for Terms of Service documents
This allows for adding Terms of Service documents to the database that
registered users need to accept before using the AUR. A revision field
can be used to indicate whether a document was updated. If it is
increased, all users are again asked to accept the new terms.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-30 16:47:13 +02:00
Lukas Fleischer
6892ec7791 Call check_sid() from a central location
Instead of calling check_sid() from every single PHP script representing
a web page, add the call to aur.inc.php which is sourced by all of them.

Also, remove set_lang() calls from the scripts since these are also
already included in aur.inc.php.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-27 09:22:53 +02:00
Lukas Fleischer
e4dcd913d1 Support headings in package comments
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-26 06:43:12 +02:00
Lukas Fleischer
dec9077339 Initialize PackageRequests.{Comments,ClosureComment}
Since commit 09cb61a (schema: Remove invalid default values for TEXT
columns, 2017-04-15), the PackageRequests.Comments and
PackageRequests.ClosureComment fields no longer have a default value.
Initialize these fields explicitly whenever a new row is added to the
PackageRequests table.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-25 07:00:53 +02:00
Lukas Fleischer
f4e2d143ad Explicitly initialize PackageBases.FlaggerComment
Since commit 09cb61a (schema: Remove invalid default values for TEXT
columns, 2017-04-15), the PackageBases.FlaggerComment field no longer
has a default value. Initialize this field explicitly whenever a new row
is added to the PackageBases table.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-25 07:00:52 +02:00
Lukas Fleischer
90ab7c7b83 t1300: Factor out package dumping
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-25 07:00:23 +02:00
Lukas Fleischer
4be9aa6350 Fix the comment collapse feature
In commit 4abde89 (Use JavaScript to collapse long comments,
2017-04-19), support for collapsing/expanding long comments was added.
This was broken by the recent Markdown support since comments no longer
live inside a single HTML paragraph. Fix this by wrapping each comment
in another div container.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
fd880a7a84 Support fenced code in package comments
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
362ee754e7 Do not keep line breaks in comments
With the new Markdown support, text paragraphs are now properly
converted to HTML paragraphs, so we no longer need to keep line breaks.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 21:10:02 +02:00
Lukas Fleischer
136171e509 Rerender package comments after editing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +02:00
Lukas Fleischer
482bd10a8b t2600: Test Markdown and HTML sanitizing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +02:00
Lukas Fleischer
bb623fc545 Make references to Git commits clickable
Automatically detect Git commit identifiers, shorten them, and make them
link to the cgit interface.

Implements FS#43290.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +02:00
Lukas Fleischer
a9ac385cb9 Reintroduce backwards-compatible hyperlink syntax
Before switching to the new comment rendering script and Markdown, no
special syntax was needed to make URLs clickable. Reintroduce this
feature and automatically detect links in addition to the hyperlink
syntax already supported by Markdown.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-23 18:43:26 +02:00
Lukas Fleischer
9aa4203c7e Add Markdown support to package comments
Support Markdown syntax in package comments. Among other things, this
makes it easier to paste command line output and patches.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-23 18:43:26 +02:00
Lukas Fleischer
016b40f99d Render comments when storing them in the database
Instead of converting package comments from plain text to HTML code when
they are displayed, do the conversion when the comment is posted and
store the rendered result in the database. The conversion itself is done
by a Python script which uses Bleach for sanitizing the text.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-23 18:43:26 +02:00
Lukas Fleischer
4abde895a5 Use JavaScript to collapse long comments
Instead of using CSS to limit the height of package comments as
implemented in 7b13203 (Limit comment height to 15 lines, 2016-03-12),
use JavaScript to collapse long comments and add a link to expand them.
Clicking the same link twice results in the corresponding comment being
collapsed again.

If JavaScript is disabled, the full comments are shown (without any
possibility to collapse or expand).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-20 07:03:54 +02:00
Lukas Fleischer
44858e0618 Store dependency descriptions in a separate column
Split optional dependency descriptions from dependency names before
storing them in the database and use a separate column to store the
descriptions.

This allows us to simplify and optimize the SQL queries in
pkg_dependencies() as well as pkg_required().

Suggested-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-19 09:13:09 +02:00
Lukas Fleischer
15501972bc Check return value of get_extended_fields()
Make sure that the get_extended_fields() invocation succeeded before
merging regular and extended fields in process_query().

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:45:02 +02:00
Lukas Fleischer
4f662c773d Check query return value in db_cache_value()
Instead of unconditionally calling fetch on the return value of query(),
error out early if the value evaluates to false.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:40:22 +02:00
Lukas Fleischer
6090c2ae8b Check query return value in search_results_page()
Instead of unconditionally calling fetch on the return value of query(),
error out early if the value evaluates to false. Also, make sure that
the results array is always initialized, even if the result set is
empty.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:38:13 +02:00
Lukas Fleischer
5553d01ab3 Check query return value in pkgbase_user_notify()
Instead of unconditionally calling fetch on the return value of query(),
error out early if the value evaluates to false.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-18 08:37:31 +02:00
Florian Pritz
102dad49e7 schema: Fix invalid NULL on primary key
>From the mysql 5.7 breaking change page:

Columns in a PRIMARY KEY must be NOT NULL, but if declared explicitly as
NULL produced no error. Now an error occurs. For example, a statement
such as CREATE TABLE t (i INT NULL PRIMARY KEY) is rejected. The same
occurs for similar ALTER TABLE statements. (Bug #13995622, Bug #66987,
Bug #15967545, Bug #16545198)

References:
http://stackoverflow.com/a/22314073

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-16 10:35:49 +02:00
Florian Pritz
09cb61ab83 schema: Remove invalid default values for TEXT columns
When running in strict mode, mysql throws an error upon encountering
these definitions since they are not supported.

References:
https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-16 10:35:42 +02:00
Mark Weiman
906a8f12cc Add TESTING instructions for web interface
Add instructions to test aurweb's web interface via the PHP built-in web
server.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-12 07:26:23 +02:00
Lukas Fleischer
2c3c8417fb git-update: Check for missing pkgname entries
Reject commits containing .SRCINFO files without any pkgname entries.

Suggested-by: Bruno Pagani <bruno.n.pagani@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-06 05:57:57 +02:00
Lukas Fleischer
a7606d0e1b Release 4.5.1
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-09 06:18:34 +01:00
Lukas Fleischer
0ba88c4795 Translation updates from Transifex
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-09 06:18:06 +01:00
Lukas Fleischer
682de0ead7 index.php: Remove routes for dropped images
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-04 13:20:37 +01:00
Lukas Fleischer
9de633b1f2 test/setup.sh: Error out on missing SQLite schema
Instead of making all tests fail, error out during initialization if the
SQLite schema has not been generated.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-03 20:30:57 +01:00
Lukas Fleischer
7ee97933de account_delete.php: Fix variable name
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-02 21:44:29 +01:00
Mark Weiman
c19284c783 gendummydata.py: Fix to make it less db specific
Sqlite3 does not support the MD5 function like MySQL does, instead of the
database program hash the passwords, have Python's hashlib module do it
instead.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-01 20:29:07 +01:00
Mark Weiman
28f33e7bb1 Fix quote for Source column default
Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-01 20:29:07 +01:00
Lukas Fleischer
da4bd3b59e Add a Makefile to build an SQLite-compatible schema
Allow for automatically converting the schema into a schema that works
with SQLite by running `make` from the schema/ subdirectory. Use the new
Makefile in the test suite.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-01 20:12:57 +01:00
Lukas Fleischer
48f2837525 aur-schema.sql: Do not recreate the database
Modify the schema such that it only creates the necessary tables,
indices and predefined data. This makes it easier to import the schema
into a database with a name other than "AUR".

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-01 20:01:29 +01:00
Lukas Fleischer
1af5ba64e7 pkgbase.php: Fix PHP notice
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-28 19:29:36 +01:00
Lukas Fleischer
cc84e0b7fd pkgbase.php: Squelch PHP warning
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-28 07:14:21 +01:00
Lukas Fleischer
eb6ae0c685 account.php: Always initialize $success
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-28 07:09:51 +01:00
Lukas Fleischer
06cf067d4f Squelch warning in pkgbase_vote()
Do not trigger a PHP warning if there are no votes to be added or
removed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 20:11:15 +01:00
Lukas Fleischer
92f140c5ca flag_comment.php: Hide comment for unflagged packages
Only show the comment paragraph if the package base is actually flagged
out-of-date.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 20:01:50 +01:00
Lukas Fleischer
483c8f5178 Remove bogus if-statement from pkgbase_delete()
The variable $action is always undefined in pkgbase_delete() which makes
the if-statement always true and triggers a warning whenever a package
base is removed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 19:56:30 +01:00
Lukas Fleischer
c557f348c4 Fix SQL query to retrieve language setting
In commit e171f6f (Migrate all DB code to use PDO, 2012-08-08),
PDOStatement::fetchAll() was introduced as a drop-in replacement for
mysql_fetch_array(). However, PDOStatement::fetchAll() returns a list of
all results while mysql_fetch_array() returns a single result only.
Instead of adding the missing indirection, simplify the code by using
PDO::fetchColumn().

Also add some safeguards to prevent warnings if the result set returned
by the query is empty.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 19:49:15 +01:00
Lukas Fleischer
62341a3b34 Fix warning with invalid time zone
The SQL query retrieving the time zone from the database may return an
empty result set if the session timeout was reached. Handle such cases
gracefully by leaving the timezone variable unset.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:20:00 +01:00
Lukas Fleischer
1bedf736e8 Fix more warnings occurring with unset SSH keys
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:20:00 +01:00
Lukas Fleischer
f1d95c09a8 pkgflag.php: Remove stray variable
Drop the fragment part of the redirection code which is an artifact of
the original code copy-pasted in commit ca954fe (Do not redirect when
showing errors during flagging, 2015-10-21).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:20:00 +01:00
Lukas Fleischer
9ec1cfa192 404.php: Squelch warning on empty PATH_INFO
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:20:00 +01:00
Lukas Fleischer
333689a885 Suppress warning on unset SSH key
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:19:08 +01:00
Lukas Fleischer
f2357a1724 Do not quote legacy variable
The $salt variable is no longer needed as of 29a4870 (Use bcrypt to hash
passwords, 2017-02-24).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-27 18:19:08 +01:00