Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fireshare",
"version": "1.7.7",
"version": "1.7.8",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.0",
Expand Down
20 changes: 15 additions & 5 deletions app/server/fireshare/api/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,20 +679,30 @@ def upload_custom_poster(video_id):
ext_map = {'image/jpeg': '.jpg', 'image/png': '.png', 'image/webp': '.webp'}
suffix = ext_map.get(file.content_type, '.jpg')

custom_poster_path = derived_dir / "custom_poster.webp"
tmp_fd, tmp_path = tempfile.mkstemp(suffix=suffix)
os.close(tmp_fd)
# Stage the conversion inside derived_dir so a failed ffmpeg run can't leave a
# corrupt custom_poster.webp behind, and so the swap is an atomic same-filesystem rename.
out_fd, out_path = tempfile.mkstemp(suffix='.webp', dir=derived_dir)
os.close(out_fd)
try:
file.save(tmp_path)
custom_poster_path = derived_dir / "custom_poster.webp"
cmd = ['ffmpeg', '-y', '-i', tmp_path, str(custom_poster_path)]
cmd = ['ffmpeg', '-y', '-i', tmp_path, out_path]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
current_app.logger.error("ffmpeg failed for custom poster: %s", result.stderr)
return jsonify({'message': 'Failed to process image'}), 500
if not os.path.getsize(out_path):
current_app.logger.error("ffmpeg produced an empty custom poster for %s", video_id)
return jsonify({'message': 'Failed to process image'}), 500
# mkstemp creates 0600; nginx serves this file directly and runs as its own user
os.chmod(out_path, 0o644)
os.replace(out_path, custom_poster_path)
finally:
os.unlink(tmp_path)

if not custom_poster_path.exists():
return jsonify({'message': 'Failed to process image'}), 500
if os.path.exists(out_path):
os.unlink(out_path)

return Response(status=200)

Expand Down
4 changes: 2 additions & 2 deletions app/server/fireshare/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .ip_whitelist import login_ip_required, get_client_ip, is_ip_permitted
from datetime import datetime, timezone
try:
import ldap
import ldap, ldap.filter
except ImportError:
ldap = None
from . import ldap_util
Expand Down Expand Up @@ -44,7 +44,7 @@ def _ldap_search(app, formatted):
def auth_user_ldap(username, password):
app = current_app._get_current_object()
formatted = app.config["LDAP_USER_FILTER"].format(
input=username,
input=ldap.filter.escape_filter_chars(username),
basedn=app.config["LDAP_BASEDN"]
)
current_app.logger.debug("authenticating %s", username)
Expand Down
Loading