This commit is contained in:
Aevann1 2022-02-06 18:51:52 +02:00
parent a6fac49071
commit 0a7d906b56
17 changed files with 27 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 210 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Before After
Before After

View file

@ -10,18 +10,25 @@ function hide_image() {
} }
document.onpaste = function(event) { document.onpaste = function(event) {
f=document.getElementById('file-upload');
files = event.clipboardData.files files = event.clipboardData.files
filename = files[0].name.toLowerCase() filename = files[0].name.toLowerCase()
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".webp") || filename.endsWith(".gif")) if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".webp") || filename.endsWith(".gif"))
{ {
f.files = files; if (document.activeElement.id == 'post-text') {
document.getElementById('filename-show').textContent = filename; document.getElementById('file-upload-submit').files = files;
document.getElementById('urlblock').classList.add('d-none'); document.getElementById('filename-show-submit').textContent = filename;
var fileReader = new FileReader(); }
fileReader.readAsDataURL(f.files[0]); else {
fileReader.addEventListener("load", function () {document.getElementById('image-preview').setAttribute('src', this.result);}); f=document.getElementById('file-upload');
document.getElementById('file-upload').setAttribute('required', 'false'); f.files = files;
document.getElementById('filename-show').textContent = filename;
document.getElementById('urlblock').classList.add('d-none');
var fileReader = new FileReader();
fileReader.readAsDataURL(f.files[0]);
fileReader.addEventListener("load", function () {document.getElementById('image-preview').setAttribute('src', this.result);});
document.getElementById('file-upload').setAttribute('required', 'false');
}
checkForRequired(); checkForRequired();
} }
} }

View file

@ -100,6 +100,8 @@ allowed_styles = ['color', 'background-color', 'font-weight', 'transform', '-web
def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
if sanitized.count(':') > 100: abort(418)
sanitized = markdown(sanitized) sanitized = markdown(sanitized)
sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace('','') sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace('','')

View file

@ -5,6 +5,7 @@ import time
from files.__main__ import app, limiter from files.__main__ import app, limiter
@app.errorhandler(400) @app.errorhandler(400)
def error_400(e): def error_400(e):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "400 Bad Request"}, 400 if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "400 Bad Request"}, 400
@ -20,7 +21,6 @@ def error_401(e):
argval = quote(f"{path}?{qs}", safe='') argval = quote(f"{path}?{qs}", safe='')
return redirect(f"{SITE_FULL}/login?redirect={argval}") return redirect(f"{SITE_FULL}/login?redirect={argval}")
@app.errorhandler(403) @app.errorhandler(403)
def error_403(e): def error_403(e):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "403 Forbidden"}, 403 if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "403 Forbidden"}, 403
@ -32,17 +32,19 @@ def error_404(e):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "404 Not Found"}, 404 if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "404 Not Found"}, 404
else: return render_template('errors/404.html', err=True), 404 else: return render_template('errors/404.html', err=True), 404
@app.errorhandler(405) @app.errorhandler(405)
def error_405(e): def error_405(e):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "405 Method Not Allowed"}, 405 if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "405 Method Not Allowed"}, 405
else: return render_template('errors/405.html', err=True), 405 else: return render_template('errors/405.html', err=True), 405
@app.errorhandler(413) @app.errorhandler(413)
def error_413(e): def error_413(e):
return {"error": "Max file size is 4 MB (8 MB for paypigs)"}, 413 return {"error": "Max file size is 4 MB (8 MB for paypigs)"}, 413
@app.errorhandler(418)
def error_418(e):
return {"error": "Too many emojis!"}, 418
@app.errorhandler(429) @app.errorhandler(429)
def error_429(e): def error_429(e):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "429 Too Many Requests"}, 429 if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "429 Too Many Requests"}, 429

View file

@ -60,7 +60,7 @@
<label class="custom-control-label" for="{{badge.id}}"></label> <label class="custom-control-label" for="{{badge.id}}"></label>
</div> </div>
</td> </td>
<td><label for="badge-{{badge.id}}"><img alt="{{badge.name}}" loading="lazy" src="/static/assets/images/badges/{{badge.id}}.webp?a=1010" width=64.16 height=70></label></td> <td><label for="badge-{{badge.id}}"><img alt="{{badge.name}}" loading="lazy" src="/static/assets/images/badges/{{badge.id}}.webp?a=1011" width=64.16 height=70></label></td>
<td>{{badge.name}}</td> <td>{{badge.name}}</td>
<td>{{badge.description}}</td> <td>{{badge.description}}</td>
</tr> </tr>

View file

@ -60,7 +60,7 @@
<label class="custom-control-label" for="{{badge.id}}"></label> <label class="custom-control-label" for="{{badge.id}}"></label>
</div> </div>
</td> </td>
<td><label for="badge-{{badge.id}}"><img alt="{{badge.name}}" loading="lazy" src="/static/assets/images/badges/{{badge.id}}.webp?a=1010" width=64.16 height=70></label></td> <td><label for="badge-{{badge.id}}"><img alt="{{badge.name}}" loading="lazy" src="/static/assets/images/badges/{{badge.id}}.webp?a=1011" width=64.16 height=70></label></td>
<td>{{badge.name}}</td> <td>{{badge.name}}</td>
<td>{{badge.description}}</td> <td>{{badge.description}}</td>
</tr> </tr>

View file

@ -23,7 +23,7 @@
<tr> <tr>
<td style="font-weight:bold">{{loop.index}}</td> <td style="font-weight:bold">{{loop.index}}</td>
<td>{{badge.name}}</td> <td>{{badge.name}}</td>
<td><img alt="{{badge.name}}" loading="lazy" src="/static/assets/images/badges/{{badge.id}}.webp?a=1010" width=45.83 height=50> <td><img alt="{{badge.name}}" loading="lazy" src="/static/assets/images/badges/{{badge.id}}.webp?a=1011" width=45.83 height=50>
<td>{{badge.description}}</td> <td>{{badge.description}}</td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -14,7 +14,7 @@
<td style="font-weight:bold;">{{loop.index}}</td> <td style="font-weight:bold;">{{loop.index}}</td>
<td><a style="color:#{{u.namecolor}}; font-weight:bold;" href="/@{{u.username}}"><img alt="@{{u.username}}'s profile picture" loading="lazy" src="{{u.profile_url}}" class="pp20"><span {% if u.patron %}class="patron" style="background-color:#{{u.namecolor}}"{% endif %}>{{u.username}}</span></a></td> <td><a style="color:#{{u.namecolor}}; font-weight:bold;" href="/@{{u.username}}"><img alt="@{{u.username}}'s profile picture" loading="lazy" src="{{u.profile_url}}" class="pp20"><span {% if u.patron %}class="patron" style="background-color:#{{u.namecolor}}"{% endif %}>{{u.username}}</span></a></td>
<td><img alt="2{{u.patron}}" loading="lazy" width=29.33 height=32 src="/static/assets/images/badges/2{{u.patron}}.webp?a=1010"></td> <td><img alt="2{{u.patron}}" loading="lazy" width=29.33 height=32 src="/static/assets/images/badges/2{{u.patron}}.webp?a=1011"></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View file

@ -258,7 +258,7 @@
<script src="/static/assets/js/marked.js?a=240"></script> <script src="/static/assets/js/marked.js?a=240"></script>
<script src="/static/assets/js/formatting.js?a=240"></script> <script src="/static/assets/js/formatting.js?a=240"></script>
<script src="/static/assets/js/submit.js?a=242"></script> <script src="/static/assets/js/submit.js?a=243"></script>
{% include "emoji_modal.html" %} {% include "emoji_modal.html" %}
{% include "gif_modal.html" %} {% include "gif_modal.html" %}