Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Video AG Infrastruktur
website
Commits
a10ae18d
Commit
a10ae18d
authored
3 years ago
by
Magnus Giesbert
Committed by
Julian Rother
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Get url path before unquote + change Thumbnail check
parent
9455a902
No related branches found
No related tags found
1 merge request
!41
Get url path before unquote + change Thumbnail check
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+15
-10
15 additions, 10 deletions
server.py
with
15 additions
and
10 deletions
server.py
+
15
−
10
View file @
a10ae18d
...
...
@@ -426,16 +426,21 @@ def logout():
def
auth
():
#pylint: disable=too-many-branches
if
'
X-Original-Uri
'
not
in
request
.
headers
:
return
'
Internal Server Error
'
,
500
url
=
urllib
.
parse
.
unquote
(
request
.
headers
[
'
X-Original-Uri
'
]).
lstrip
(
config
[
'
VIDEOPREFIX
'
])
url_path
=
urllib
.
parse
.
urlparse
(
request
.
headers
[
'
X-Original-Uri
'
]).
path
url_path
=
urllib
.
parse
.
unquote
(
url_path
)
url_prefix
=
config
[
'
VIDEOPREFIX
'
]
+
'
/
'
if
url_path
.
startswith
(
url_prefix
):
url_path
=
url_path
[
len
(
url_prefix
):]
# remove prefix followed by '/'
else
:
return
'
Internal Server Error
'
,
500
if
request
.
cookies
.
get
(
'
tracking
'
,
''
)
and
request
.
cookies
[
'
tracking
'
].
isdigit
():
cookie
=
int
(
request
.
cookies
[
'
tracking
'
])
else
:
cookie
=
random
.
getrandbits
(
8
*
8
-
1
)
url_path
=
urllib
.
parse
.
urlparse
(
url
).
path
if
url_path
.
endswith
(
'
jpg
'
)
or
ismod
():
if
url_path
.
startswith
(
'
thumbnail/
'
)
or
ismod
():
return
"
OK
"
,
200
if
url
.
startswith
(
'
pub/hls/
'
):
handle
=
url
[
len
(
'
pub/hls/
'
):].
split
(
'
_
'
)[
0
].
split
(
'
.
'
)[
0
]
if
url
_path
.
startswith
(
'
pub/hls/
'
):
handle
=
url
_path
[
len
(
'
pub/hls/
'
):].
split
(
'
_
'
)[
0
].
split
(
'
.
'
)[
0
]
if
handle
.
isdigit
():
perms
=
query
(
'''
SELECT lectures.id AS lecture, perm.*
FROM lectures
...
...
@@ -462,7 +467,7 @@ def auth(): #pylint: disable=too-many-branches
WHERE videos.path = ?
AND (courses.visible AND lectures.visible AND videos.visible)
ORDER BY perm.video_id DESC, perm.lecture_id DESC, perm.course_id DESC
'''
,
url
)
url
_path
)
if
not
perms
:
return
"
Not found
"
,
404
auth
=
request
.
authorization
...
...
@@ -472,12 +477,12 @@ def auth(): #pylint: disable=too-many-branches
password
=
auth
.
password
if
checkperm
(
perms
,
username
=
username
,
password
=
password
):
try
:
if
not
url
.
startswith
(
'
pub/hls/
'
):
if
not
url
_path
.
startswith
(
'
pub/hls/
'
):
modify
(
'
INSERT INTO log (id, `time`, `date`, video, source) VALUES (?, ?, ?, ?, 1)
'
,
cookie
,
datetime
.
now
(),
datetime
.
combine
(
date
.
today
(),
time
()),
perms
[
0
][
'
vid
'
])
elif
url
.
endswith
(
'
.ts
'
):
fmt
=
url
.
split
(
'
_
'
)[
-
1
].
split
(
'
-
'
)[
0
]
seg
=
url
.
split
(
'
.
'
)[
0
].
split
(
'
-
'
)[
-
1
]
elif
url
_path
.
endswith
(
'
.ts
'
):
fmt
=
url
_path
.
split
(
'
_
'
)[
-
1
].
split
(
'
-
'
)[
0
]
seg
=
url
_path
.
split
(
'
.
'
)[
0
].
split
(
'
-
'
)[
-
1
]
modify
(
'
INSERT INTO hlslog (id, `time`, segment, lecture, handle, format) VALUES (?, ?, ?, ?, ?, ?)
'
,
cookie
,
datetime
.
now
(),
seg
,
perms
[
0
][
'
lecture
'
],
handle
,
fmt
)
except
:
#pylint: disable=bare-except
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment