Commit graph

1698 commits

Author SHA1 Message Date
Lukas Fleischer
ad9422ca19 confparser.inc.php: Add missing semicolon
Fixes a regression introduced in 97c5bce (config: allow reading both the
defaults file and the modified config, 2018-04-15).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-05-12 12:25:21 +02:00
Eli Schwartz
0ffa0679d2 Use a link to accept orphan requests
Currently, a form is used instead of a link. This forwards to a
confirmation page, and currently drops the "via" parameter in the
process.

As a result, accepted orphan requests usually show:

    Request #XXXXXX has been accepted automatically by the Arch User
    Repository package request system:

    The user YYYYYYY disowned the package.

This is wrong, and should show (will show, if you manually add it or use
the close button instead of the accept button):

    Request #XXXXXX has been rejected by YYYYYYY [1]:

Fixes FS#56606.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-05-11 11:23:52 +02:00
Eli Schwartz
4381a0d7c2 Update copyright year in the cgit footer template
Four years just passed in the blink of an eye :)

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-05-10 09:29:03 +02:00
Eli Schwartz
97c5bcec13 config: allow reading both the defaults file and the modified config
In the process, rename config.proto to config.defaults (because that is
what it is now).

Also use dict.get('key', default_value) when querying os.environ, rather
than an if block, as it is more pythonic/readable/concise, and reduces
the number of dict lookups.

This change allows aurweb configuration to be done via either:
- copying config.defaults to config and modifying values
- creating a new config only containing modified values, next to a
  config.defaults containing unmodified values

The motivation for this change is to enable ansible configuration in our
flagship deployment by storing only changed values, and deferring to
config.defaults otherwise.

A side benefit is, it is easier to see what has changed by inspecting
only the site configuration file.

If a config.defaults file does not exist next to $AUR_CONFIG or in
$AUR_CONFIG_DEFAULTS, it is ignored and *all* values are expected to
live in the modified config file.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-04-22 09:26:10 +02:00
nodivbyzero
eccd328d42 Handle empty resultset getting recent 10 packages
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-21 07:45:26 +01:00
nodivbyzero
3d90623154 Terminate execution if config file is missing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-20 19:23:02 +01:00
Jelle van der Waa
ca6332de6e Update cache code to INI style configuration
Change the defines to config_get and add one cache option and one option
to define memcache_servers. Mention the required dependency to get
memcached working in the INSTALL file.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-10 16:48:14 +01:00
Jelle van der Waa
c3bca45973 Remove unused variable $dbh in pkgbase_display_details
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-03-10 16:47:11 +01:00
Baptiste Jonglez
1ff409874e RPC: Allow to search packages by "*depends" fields
It is now possible to search for packages that depend on a given package,
for instance:

    /rpc/?v=5&type=search&by=depends&arg=ocaml

It is similarly possible to match on "makedepends", "checkdepends" and
"optdepends".

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Mark Weiman
f15c700ad2 Add capability for co-maintainers to disown packages
Implements FS#53832.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Florian Pritz
27654afadb Add rate limit support to API
This allows us to prevent users from hammering the API every few seconds
to check if any of their packages were updated. Real world users check
as often as every 5 or 10 seconds.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Florian Pritz
f51d4c32cd Remove disjunction in pkg_providers query
For some reason, running the SELECT .. WHERE .. OR .. query takes e.g.
58ms on a randomly generated db for some dependency name. Splitting the
OR into two dedicated queries and UNIONing the result takes only 0.42ms.

On the Arch Linux installation, searching for the providers of e.g.
mongodb takes >=110ms when not cached by the query cache. The new query
takes <1ms even when not cached.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Eli Schwartz
ac29097ce8 Fix regression that stopped maintainers from pinning comments
In commit 8c98db0b82 support was added for
package co-maintainers to pin comments in addition to maintainers.

Due to a typo, the SQL query was reset halfway through and only added
the co-maintainer IDs to the list of allowed users.

Fixes FS#56783.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-23 22:51:39 +01:00
Lukas Fleischer
a04fe6a13e Add route for /users.gz
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-03 13:59:54 +01:00
Lukas Fleischer
4660892e58 Allow setting an empty home page
Since commit 4efba18 (Only allow valid HTTP(s) URLs as home page,
2017-11-05), the home page field in the account settings must be a valid
URL. However, this new check prevents from leaving the field empty. Keep
the check in place but skip it if the home page field is left empty.

Fixes FS#56550.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-03 13:52:28 +01:00
Lukas Fleischer
0333d475fa Release 4.6.0
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-03 10:23:46 +01:00
Lukas Fleischer
3be28d016f Sync CSS with archweb
This partially fixes FS#56472.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-28 08:52:12 +01:00
Lukas Fleischer
0aa67b278a Fix sorting order when clicking table headings
A bug introduced in commit 7d7e079 (Hide the table sorting links on the
dashboard, 2017-02-04) resulted in multiple clicks on a table heading in
the package search results table no longer having any effect, instead of
changing the sorting order. Fix this by removing erroneous spaces from
the GET parameters in the search URL.

Fixes FS#56261.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-07 21:36:42 +01:00
Lukas Fleischer
8c98db0b82 Allow package co-maintainers to pin comments
Implements FS#56255.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-06 17:03:37 +01:00
Lukas Fleischer
e2fa5ea6fa login.php: Escape quotes in the referer field
Replace special characters in the referer GET parameter using
htmlspecialchars() before inserting it into the login form fields to
prevent from XSS attacks.

Fixes FS#55286.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 11:28:11 +01:00
Lukas Fleischer
4efba18f86 Only allow valid HTTP(s) URLs as home page
The home page specified in the account settings is converted to a
clickable link on the user's profile. Make sure it is a valid URL which
uses the http or https scheme.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 08:55:24 +01:00
Lukas Fleischer
c859e371b0 Set X-Frame-Options to DENY for all pages
Do not allow to render aurweb pages in a frame to protect against
clickjacking.

Fixes FS#56168.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 08:36:23 +01:00
Lukas Fleischer
6c95fa3d1e Point out that the user name is public when registering
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-05 08:24:51 +01:00
Lukas Fleischer
e06773add6 Unset PackagerUID before deleting an account
When removing an account, remove the user from all last packager fields
before deletion to make sure that no package bases are deleted, even if
propagation constraints are missing.

Fixes FS#53956.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-08-01 07:02:44 +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
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
136171e509 Rerender package comments after editing
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-24 17:41:35 +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
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
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
7ee97933de account_delete.php: Fix variable name
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-03-02 21:44: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