Tento commit je obsažen v:
sneedmaster 2024-02-21 16:15:07 +01:00
rodič 3ed82b79a9
revize cc6921d4ed
6 změnil soubory, kde provedl 54 přidání a 223 odebrání

180
Cargo.lock vygenerováno
Zobrazit soubor

@ -484,12 +484,6 @@ dependencies = [
"serde",
]
[[package]]
name = "bit_field"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
[[package]]
name = "bitflags"
version = "1.3.2"
@ -759,40 +753,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.8"
@ -812,12 +772,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "crypto-common"
version = "0.1.6"
@ -1124,22 +1078,6 @@ version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
name = "exr"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1e481eb11a482815d3e9d618db8c42a93207134662873809335a92327440c18"
dependencies = [
"bit_field",
"flume",
"half",
"lebe",
"miniz_oxide",
"rayon-core",
"smallvec",
"zune-inflate",
]
[[package]]
name = "fallible_collections"
version = "0.4.9"
@ -1182,7 +1120,6 @@ checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577"
dependencies = [
"futures-core",
"futures-sink",
"nanorand",
"pin-project",
"spin 0.9.8",
]
@ -1297,20 +1234,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi",
"wasm-bindgen",
]
[[package]]
name = "gif"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045"
dependencies = [
"color_quant",
"weezl",
]
[[package]]
@ -1344,15 +1269,6 @@ dependencies = [
"tracing",
]
[[package]]
name = "half"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0"
dependencies = [
"crunchy",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
@ -1564,14 +1480,9 @@ dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"exr",
"gif",
"jpeg-decoder",
"num-rational",
"num-traits",
"png",
"qoi",
"tiff",
]
[[package]]
@ -1627,15 +1538,6 @@ dependencies = [
"libc",
]
[[package]]
name = "jpeg-decoder"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
dependencies = [
"rayon",
]
[[package]]
name = "js-sys"
version = "0.3.64"
@ -1674,12 +1576,6 @@ dependencies = [
"spin 0.5.2",
]
[[package]]
name = "lebe"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]]
name = "libc"
version = "0.2.149"
@ -1782,15 +1678,6 @@ version = "2.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
[[package]]
name = "memoffset"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
[[package]]
name = "mime"
version = "0.3.17"
@ -1841,15 +1728,6 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "nanorand"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
dependencies = [
"getrandom",
]
[[package]]
name = "nekrochan"
version = "0.1.0"
@ -1869,7 +1747,6 @@ dependencies = [
"fs_extra",
"glob",
"html-minifier",
"image",
"ipnetwork",
"jsonwebtoken",
"lazy_static",
@ -2215,15 +2092,6 @@ dependencies = [
"sha2 0.9.9",
]
[[package]]
name = "qoi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
dependencies = [
"bytemuck",
]
[[package]]
name = "quote"
version = "1.0.32"
@ -2263,28 +2131,6 @@ dependencies = [
"getrandom",
]
[[package]]
name = "rayon"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
"num_cpus",
]
[[package]]
name = "redis"
version = "0.24.0"
@ -2965,17 +2811,6 @@ dependencies = [
"syn 2.0.28",
]
[[package]]
name = "tiff"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211"
dependencies = [
"flate2",
"jpeg-decoder",
"weezl",
]
[[package]]
name = "time"
version = "0.3.22"
@ -3289,12 +3124,6 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
[[package]]
name = "weezl"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]]
name = "whoami"
version = "1.4.1"
@ -3508,12 +3337,3 @@ dependencies = [
"libc",
"pkg-config",
]
[[package]]
name = "zune-inflate"
version = "0.2.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
dependencies = [
"simd-adler32",
]

Zobrazit soubor

@ -17,7 +17,6 @@ enumflags2 = "0.7.7"
encoding = "0.2.33"
env_logger = "0.11.2"
glob = "0.3.1"
image = "0.24.7"
ipnetwork = "0.20.0"
jsonwebtoken = "9.1.0"
lazy_static = "1.4.0"

Zobrazit soubor

@ -94,8 +94,9 @@ pub async fn create_post(
None => None,
};
if (thread.is_none() && board.config.0.thread_captcha != "off")
|| (thread.is_some() && board.config.0.reply_captcha != "off")
if !(perms.owner() || perms.bypass_captcha())
&& ((thread.is_none() && board.config.0.thread_captcha != "off")
|| (thread.is_some() && board.config.0.reply_captcha != "off"))
{
let board = board.id.clone();
@ -104,13 +105,18 @@ pub async fn create_post(
.ok_or(NekrochanError::RequiredCaptchaError)?
.0;
if id.is_empty() {
return Err(NekrochanError::RequiredCaptchaError);
}
let key = format!("captcha:{board}:{id}");
let solution = form
.captcha_solution
.ok_or(NekrochanError::RequiredCaptchaError)?;
let actual_solution: String = ctx.cache().get_del(key).await?;
let actual_solution: Option<String> = ctx.cache().get_del(key).await?;
let actual_solution = actual_solution.ok_or(NekrochanError::InvalidCaptchaError)?;
if solution.trim() != actual_solution {
return Err(NekrochanError::IncorrectCaptchaError);

Zobrazit soubor

@ -12,8 +12,8 @@ $(function () {
$.get(req_url, function (data, _) {
try {
$("#captcha").replaceWith(`<img id="captcha" src="data:image/png;base64,${data.png}">`);
$("#captcha-id").prop("value", data.id);
$("#captcha").html(`<img src="data:image/png;base64,${data.png}">`);
} catch {
btn.append(" [Chyba]");
}

Zobrazit soubor

@ -157,7 +157,7 @@ summary {
color: var(--text);
background-color: var(--input-color);
border: 1px solid var(--input-border);
padding: 8px;
padding: 4px;
}
.main {
@ -475,14 +475,20 @@ summary {
cursor: wait;
}
img#captcha {
#captcha {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: block;
width: 100%;
image-rendering: pixelated;
height: 120px;
border: 1px solid var(--input-border);
}
#captcha img {
display: block;
height: 100%;
image-rendering: pixelated;
margin: 0px auto;
}

Zobrazit soubor

@ -28,6 +28,40 @@
<textarea name="content" {% if (!reply && board.config.0.require_thread_content) || (reply && board.config.0.require_reply_content) %}required=""{% endif %}></textarea>
</td>
</tr>
{% if !(tcx.perms.bypass_captcha() || tcx.perms.owner()) %}
{% let difficulty %}
{% if reply %}
{% let difficulty = board.config.0.reply_captcha.as_str() %}
{% else %}
{% let difficulty = board.config.0.thread_captcha.as_str() %}
{% endif %}
{% if (!reply && board.config.0.thread_captcha != "off") || (reply && board.config.0.reply_captcha != "off") %}
<tr>
<td class="label">
CAPTCHA<br>
<span class="small">(vyprší za 10 min.)</span>
<noscript><span class="small">(VYŽADUJE JAVASCRIPT)</span></noscript>
</td>
<td>
<div class="input-wrapper">
<table class="full-width">
<input id="captcha-id" name="captcha_id" type="hidden">
<tr>
<td>
<button id="get-captcha" type="button" class="button" data-board="{{ board.id }}" data-reply="{{ reply }}">Získat CAPTCHA</button>
</td>
<td>
<input name="captcha_solution" type="text" placeholder="Řešení" value="" required="">
</tr>
</tr>
<tr><td colspan="2"><div id="captcha"></div></tr>
</table>
</div>
</td>
</tr>
{% endif %}
{% endif %}
<tr>
<td class="label">
{% if board.config.0.file_limit > 1 %}
@ -54,40 +88,6 @@
<td class="label">Heslo <span class="small">(na odstranění)</span></td>
<td><input name="password" type="password" required=""></td>
</tr>
{% if !(tcx.perms.bypass_captcha() || tcx.perms.owner()) %}
{% let difficulty %}
{% if reply %}
{% let difficulty = board.config.0.reply_captcha.as_str() %}
{% else %}
{% let difficulty = board.config.0.thread_captcha.as_str() %}
{% endif %}
{% if (!reply && board.config.0.thread_captcha != "off") || (reply && board.config.0.reply_captcha != "off") %}
<noscript>
<tr>
<td colspan="2">
<div class="reply-mode">CAPTCHA vyžaduje JavaScript</div>
</td>
</tr>
</noscript>
<tr>
<td class="label">
CAPTCHA<br>
<span class="small">(vyprší za 10 min.)</span>
</td>
<td>
<div class="input-wrapper">
<table class="full-width">
<tr><td><button id="get-captcha" type="button" class="button" data-board="{{ board.id }}" data-reply="{{ reply }}">Získat CAPTCHA</button></td></tr>
<tr><td><div id="captcha"></div></tr>
<input id="captcha-id" name="captcha_id" type="hidden" required="">
<tr><td><input name="captcha_solution" type="text" placeholder="Řešení" required=""></tr></td>
</table>
</div>
</td>
</tr>
{% endif %}
{% endif %}
<tr>
{% if reply %}
<td colspan="2"><input class="button" type="submit" value="Nová odpověď"></td>