Compare commits

...

5 commits

Author SHA1 Message Date
n1rwana
59156cd605
Merge a16e15eaef into 228f14e384 2025-01-31 11:18:52 +02:00
koke228666
228f14e384
feat(documents): add download icon for documents (#1216) 2025-01-31 00:39:58 +02:00
celestora
4166481a75
fix(im): escape html in sent messages too (#1218)
fixes #1215
2025-01-30 00:13:20 +03:00
7fe0c6a122
ci(actions): unparallel builds (#1217)
this should fix linux/amd64 showing up as unknown/unknown on ghcr
2025-01-28 20:41:26 +03:00
n1rwana
a16e15eaef
Фикс проверки заблокированных ссылок 2023-08-05 14:49:41 +03:00
8 changed files with 147 additions and 132 deletions

View file

@ -3,142 +3,140 @@ name: Build images
on: [push, pull_request] on: [push, pull_request]
env: env:
BASE_IMAGE_NAME: openvk BASE_IMAGE_NAME: openvk
DB_IMAGE_NAME: mariadb DB_IMAGE_NAME: mariadb
EVENT_IMAGE_NAME: mariadb EVENT_IMAGE_NAME: mariadb
DB_VERSION: "10.9" DB_VERSION: '10.9'
jobs: jobs:
buildbase: buildbase:
name: Build base images name: Build base images
strategy:
matrix:
platform: [amd64, arm64]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Change repository string to lowercase - name: Set up Docker Buildx
id: repositorystring id: buildx
uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0 uses: docker/setup-buildx-action@v3
with: with:
string: ${{ github.repository }} platforms: linux/amd64,linux/arm64
- name: Base image meta - name: Change repository string to lowercase
id: basemeta id: repositorystring
uses: docker/metadata-action@v5 uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0
with: with:
images: | string: ${{ github.repository }}
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.BASE_IMAGE_NAME}}
labels: |
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Log into registry - name: Base image meta
if: github.event_name != 'pull_request' id: basemeta
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.BASE_IMAGE_NAME}}
labels: |
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Build base image - name: Log into registry
uses: docker/build-push-action@v6 if: github.event_name != 'pull_request'
with: run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
platforms: linux/${{matrix.platform}}
file: install/automated/docker/openvk.Dockerfile
tags: ${{ steps.basemeta.outputs.tags }}
labels: ${{ steps.basemeta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
GITREPO=${{ steps.repositorystring.outputs.lowercase }}
builddb: - name: Build base image
name: Build DB images uses: docker/build-push-action@v6
strategy: with:
matrix: platforms: linux/amd64,linux/arm64
platform: [amd64, arm64] file: install/automated/docker/openvk.Dockerfile
tags: ${{ steps.basemeta.outputs.tags }}
labels: ${{ steps.basemeta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
GITREPO=${{ steps.repositorystring.outputs.lowercase }}
runs-on: ubuntu-latest builddb:
name: Build DB images
steps: runs-on: ubuntu-latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Change repository string to lowercase steps:
id: repositorystring - name: Set up QEMU
uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0 uses: docker/setup-qemu-action@v3
with:
string: ${{ github.repository }}
- name: MariaDB primary meta - name: Set up Docker Buildx
id: db-primarymeta id: buildx
uses: docker/metadata-action@v5 uses: docker/setup-buildx-action@v3
with: with:
images: | platforms: linux/amd64,linux/arm64
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
labels: |
org.opencontainers.image.title=OpenVK MariaDB (Primary)
org.opencontainers.image.description=OpenVK's image for MariaDB for primary database.
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
tags: |
type=sha,prefix=${{env.DB_VERSION}}-primary-sha-
type=ref,event=branch,prefix=${{env.DB_VERSION}}-primary-
type=ref,event=pr,prefix=${{env.DB_VERSION}}-primary-pr-
type=ref,event=tag,prefix=${{env.DB_VERSION}}-primary-
type=raw,value=${{env.DB_VERSION}}-primary,enable={{is_default_branch}}
- name: MariaDB event meta - name: Change repository string to lowercase
id: db-eventmeta id: repositorystring
uses: docker/metadata-action@v5 uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0
with: with:
images: | string: ${{ github.repository }}
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
labels: |
org.opencontainers.image.title=OpenVK MariaDB (EventDB)
org.opencontainers.image.description=OpenVK's image for MariaDB for event database.
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
tags: |
type=sha,prefix=${{env.DB_VERSION}}-eventdb-sha-
type=ref,event=branch,prefix=${{env.DB_VERSION}}-eventdb-
type=ref,event=pr,prefix=${{env.DB_VERSION}}-eventdb-pr-
type=ref,event=tag,prefix=${{env.DB_VERSION}}-eventdb-
type=raw,value=${{env.DB_VERSION}}-eventdb,enable={{is_default_branch}}
- name: Log into registry - name: MariaDB primary meta
if: github.event_name != 'pull_request' id: db-primarymeta
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin uses: docker/metadata-action@v5
with:
- name: Build MariaDB primary image images: |
uses: docker/build-push-action@v6 ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
with: labels: |
push: ${{ github.event_name != 'pull_request' }} org.opencontainers.image.title=OpenVK MariaDB (Primary)
platforms: linux/${{matrix.platform}} org.opencontainers.image.description=OpenVK's image for MariaDB for primary database.
file: install/automated/docker/mariadb-primary.Dockerfile org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
tags: ${{ steps.db-primarymeta.outputs.tags }} tags: |
labels: ${{ steps.db-primarymeta.outputs.labels }} type=sha,prefix=${{env.DB_VERSION}}-primary-sha-
build-args: | type=ref,event=branch,prefix=${{env.DB_VERSION}}-primary-
VERSION=${{env.DB_VERSION}} type=ref,event=pr,prefix=${{env.DB_VERSION}}-primary-pr-
type=ref,event=tag,prefix=${{env.DB_VERSION}}-primary-
- name: Build MariaDB event image type=raw,value=${{env.DB_VERSION}}-primary,enable={{is_default_branch}}
uses: docker/build-push-action@v6
with: - name: MariaDB event meta
push: ${{ github.event_name != 'pull_request' }} id: db-eventmeta
platforms: linux/${{matrix.platform}} uses: docker/metadata-action@v5
file: install/automated/docker/mariadb-eventdb.Dockerfile with:
tags: ${{ steps.db-eventmeta.outputs.tags }} images: |
labels: ${{ steps.db-eventmeta.outputs.labels }} ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
build-args: | labels: |
VERSION=${{env.DB_VERSION}} org.opencontainers.image.title=OpenVK MariaDB (EventDB)
org.opencontainers.image.description=OpenVK's image for MariaDB for event database.
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
tags: |
type=sha,prefix=${{env.DB_VERSION}}-eventdb-sha-
type=ref,event=branch,prefix=${{env.DB_VERSION}}-eventdb-
type=ref,event=pr,prefix=${{env.DB_VERSION}}-eventdb-pr-
type=ref,event=tag,prefix=${{env.DB_VERSION}}-eventdb-
type=raw,value=${{env.DB_VERSION}}-eventdb,enable={{is_default_branch}}
- name: Log into registry
if: github.event_name != 'pull_request'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build MariaDB primary image
uses: docker/build-push-action@v6
with:
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
file: install/automated/docker/mariadb-primary.Dockerfile
tags: ${{ steps.db-primarymeta.outputs.tags }}
labels: ${{ steps.db-primarymeta.outputs.labels }}
build-args: |
VERSION=${{env.DB_VERSION}}
- name: Build MariaDB event image
uses: docker/build-push-action@v6
with:
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
file: install/automated/docker/mariadb-eventdb.Dockerfile
tags: ${{ steps.db-eventmeta.outputs.tags }}
labels: ${{ steps.db-eventmeta.outputs.labels }}
build-args: |
VERSION=${{env.DB_VERSION}}

View file

@ -39,7 +39,7 @@ class BannedLink extends RowModel
function getRegexpRule(): string function getRegexpRule(): string
{ {
return addslashes("/" . $this->getDomain() . $this->getRawRegexp() . "/"); return "/^" . $this->getDomain() . "\/" . $this->getRawRegexp() . "$/i";
} }
function getRawRegexp(): string function getRawRegexp(): string

View file

@ -3,6 +3,7 @@ namespace openvk\Web\Models\Repositories;
use Chandler\Database\DatabaseConnection as DB; use Chandler\Database\DatabaseConnection as DB;
use Nette\Database\Table\{ActiveRow, Selection}; use Nette\Database\Table\{ActiveRow, Selection};
use openvk\Web\Models\Entities\BannedLink; use openvk\Web\Models\Entities\BannedLink;
use function Symfony\Component\Translation\t;
class BannedLinks class BannedLinks
{ {
@ -43,7 +44,7 @@ class BannedLinks
function isDomainBanned(string $domain): bool function isDomainBanned(string $domain): bool
{ {
return sizeof($this->bannedLinks->where(["link" => $domain, "regexp_rule" => ""])) > 0; return sizeof($this->bannedLinks->where(["domain" => $domain, "regexp_rule" => ""])) > 0;
} }
function genLinks($rules): \Traversable function genLinks($rules): \Traversable
@ -57,12 +58,14 @@ class BannedLinks
foreach($links as $link) foreach($links as $link)
if (preg_match($link->getRegexpRule(), $uri)) if (preg_match($link->getRegexpRule(), $uri))
yield $link->getId(); yield $link->getId();
else if ($this->isDomainBanned($link->getDomain()))
yield $link->getId();
} }
function check(string $url): ?array function check(string $url): ?array
{ {
$uri = strstr(str_replace(["https://", "http://"], "", $url), "/", true); $uri = str_replace(["https://", "http://"], "", $url);
$domain = str_replace("www.", "", $uri); $domain = explode("/", str_replace("www.", "", $uri))[0];
$rules = $this->getByDomain($domain); $rules = $this->getByDomain($domain);
if (is_null($rules)) if (is_null($rules))

View file

@ -481,7 +481,7 @@ final class AdminPresenter extends OpenVKPresenter
if ($link) { if ($link) {
$link->setDomain($new_domain ?? $this->postParam("link")); $link->setDomain($new_domain ?? $this->postParam("link"));
$link->setReason($new_reason); $link->setReason($new_reason);
$link->setRegexp_rule($this->postParam("regexp")); $link->setRegexp_rule(mb_strlen(trim($this->postParam("regexp"))) > 0 ? $this->postParam("regexp") : "");
$link->save(); $link->save();
} else { } else {
if (!$new_domain) if (!$new_domain)
@ -490,7 +490,7 @@ final class AdminPresenter extends OpenVKPresenter
$link = new BannedLink; $link = new BannedLink;
$link->setDomain($new_domain); $link->setDomain($new_domain);
$link->setReason($new_reason); $link->setReason($new_reason);
$link->setRegexp_rule($this->postParam("regexp")); $link->setRegexp_rule(mb_strlen(trim($this->postParam("regexp"))) > 0 ? $this->postParam("regexp") : "");
$link->setInitiator($this->user->identity->getId()); $link->setInitiator($this->user->identity->getId());
$link->save(); $link->save();

View file

@ -7,7 +7,7 @@ final class AwayPresenter extends OpenVKPresenter
{ {
function renderAway(): void function renderAway(): void
{ {
$checkBanEntries = (new BannedLinks)->check($this->queryParam("to") . "/"); $checkBanEntries = (new BannedLinks)->check($this->queryParam("to"));
if (OPENVK_ROOT_CONF["openvk"]["preferences"]["susLinks"]["warnings"]) if (OPENVK_ROOT_CONF["openvk"]["preferences"]["susLinks"]["warnings"])
if (sizeof($checkBanEntries) > 0) if (sizeof($checkBanEntries) > 0)
$this->pass("openvk!Away->view", $checkBanEntries[0]); $this->pass("openvk!Away->view", $checkBanEntries[0]);

View file

@ -232,7 +232,7 @@
sendMessage(content) { sendMessage(content) {
console.debug("New outcoming message. Pushing preview to local stack."); console.debug("New outcoming message. Pushing preview to local stack.");
let tempId = this.newMessage(content); let tempId = this.newMessage(escapeHtml(content));
let msgData = new FormData(); let msgData = new FormData();
msgData.set("content", content); msgData.set("content", content);

View file

@ -4173,6 +4173,16 @@ hr {
color: #6b6b6b; color: #6b6b6b;
} }
.doc_icon.no_image span::before {
content: '';
display: inline-block;
width: 10px;
height: 10px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAKCAYAAABmBXS+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAABYSURBVChTY2RAAvNnzmwBUtVA3JqYnl4DFgQCJigNAyAFyDQYoCvCCohSxAh0x38oGydANwmmAUUjE9AXKD5EByB5uAIka0E0WBxmAHo4wa3BawOmRxgYAOA2GQMa5cgCAAAAAElFTkSuQmCC");
transform: translateY(2px) translateX(-3px);
background-repeat: no-repeat;
}
.docListViewItem .doc_icon img { .docListViewItem .doc_icon img {
width: 100%; width: 100%;
height: 100%; height: 100%;

View file

@ -656,3 +656,7 @@ ul {
.docListViewItem .doc_content b { .docListViewItem .doc_content b {
color: #7c94c5; color: #7c94c5;
} }
.doc_icon.no_image span::before {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAKCAYAAABmBXS+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsAAAA7AAWrWiQkAAABXSURBVChTY2RAAoFe9ZuEBOR93314uHn9tkY/qDADE5QGA5ACZBoGUBThAkQpYkyOmvcfysYJiDMJROAzbe6yJEZ4EGBTCFIAolHCCVkhTAFWgGkiAwMAzxkZ3qVQ7YEAAAAASUVORK5CYII=");
}