Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
3271f73e
Commit
3271f73e
authored
7 months ago
by
Ron Lucke
Committed by
Marcus Eibrink-Lunzenauer
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix PHP 8 Warning Issues
Closes #4395 and #4408 Merge request
studip/studip!3215
parent
132e6c6b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/filesystem/FileManager.php
+5
-5
5 additions, 5 deletions
lib/filesystem/FileManager.php
lib/models/Courseware/BlockTypes/Embed.php
+19
-13
19 additions, 13 deletions
lib/models/Courseware/BlockTypes/Embed.php
with
24 additions
and
18 deletions
lib/filesystem/FileManager.php
+
5
−
5
View file @
3271f73e
...
@@ -1484,7 +1484,7 @@ class FileManager
...
@@ -1484,7 +1484,7 @@ class FileManager
$url_parts
=
@
parse_url
(
$url
);
$url_parts
=
@
parse_url
(
$url
);
// filter out localhost and reserved or private IPs
// filter out localhost and reserved or private IPs
if
(
mb_stripos
(
$url_parts
[
'host'
],
'localhost'
)
!==
false
if
(
array_key_exists
(
'host'
,
$url_parts
)
&&
(
mb_stripos
(
$url_parts
[
'host'
],
'localhost'
)
!==
false
||
mb_stripos
(
$url_parts
[
'host'
],
'loopback'
)
!==
false
||
mb_stripos
(
$url_parts
[
'host'
],
'loopback'
)
!==
false
||
(
filter_var
(
$url_parts
[
'host'
],
FILTER_VALIDATE_IP
)
!==
false
||
(
filter_var
(
$url_parts
[
'host'
],
FILTER_VALIDATE_IP
)
!==
false
&&
(
mb_strpos
(
$url_parts
[
'host'
],
'127'
)
===
0
&&
(
mb_strpos
(
$url_parts
[
'host'
],
'127'
)
===
0
...
@@ -1495,13 +1495,13 @@ class FileManager
...
@@ -1495,13 +1495,13 @@ class FileManager
|
FILTER_FLAG_NO_PRIV_RANGE
|
FILTER_FLAG_NO_PRIV_RANGE
|
FILTER_FLAG_NO_RES_RANGE
|
FILTER_FLAG_NO_RES_RANGE
)
===
false
)
)
===
false
)
)
)
)
)
{
)
{
return
[
'response'
=>
'HTTP/1.0 400 Bad Request'
,
'response_code'
=>
400
];
return
[
'response'
=>
'HTTP/1.0 400 Bad Request'
,
'response_code'
=>
400
];
}
}
// URL links to an ftp server
// URL links to an ftp server
if
(
$url_parts
[
'scheme'
]
===
'ftp'
)
{
if
(
array_key_exists
(
'scheme'
,
$url_parts
)
&&
$url_parts
[
'scheme'
]
===
'ftp'
)
{
if
(
preg_match
(
'/[^a-z0-9_.-]/i'
,
$url_parts
[
'host'
]))
{
// exists umlauts ?
if
(
preg_match
(
'/[^a-z0-9_.-]/i'
,
$url_parts
[
'host'
]))
{
// exists umlauts ?
$IDN
=
new
Algo26\IdnaConvert\ToIdn
();
$IDN
=
new
Algo26\IdnaConvert\ToIdn
();
$out
=
$IDN
->
convert
(
$url_parts
[
'host'
]);
// false by error
$out
=
$IDN
->
convert
(
$url_parts
[
'host'
]);
// false by error
...
@@ -1545,9 +1545,9 @@ class FileManager
...
@@ -1545,9 +1545,9 @@ class FileManager
if
(
!
empty
(
$url_parts
[
'query'
]))
{
if
(
!
empty
(
$url_parts
[
'query'
]))
{
$documentpath
.
=
'?'
.
$url_parts
[
'query'
];
$documentpath
.
=
'?'
.
$url_parts
[
'query'
];
}
}
$host
=
$url_parts
[
'host'
];
$host
=
$url_parts
[
'host'
]
??
null
;
$port
=
$url_parts
[
'port'
]
??
null
;
$port
=
$url_parts
[
'port'
]
??
null
;
$scheme
=
mb_strtolower
(
$url_parts
[
'scheme'
]);
$scheme
=
array_key_exists
(
'scheme'
,
$url_parts
)
?
mb_strtolower
(
$url_parts
[
'scheme'
])
:
null
;
if
(
!
in_array
(
$scheme
,
[
'http'
,
'https'
])
||
!
$host
)
{
if
(
!
in_array
(
$scheme
,
[
'http'
,
'https'
])
||
!
$host
)
{
return
[
'response'
=>
'HTTP/1.0 400 Bad Request'
,
'response_code'
=>
400
];
return
[
'response'
=>
'HTTP/1.0 400 Bad Request'
,
'response_code'
=>
400
];
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/models/Courseware/BlockTypes/Embed.php
+
19
−
13
View file @
3271f73e
...
@@ -49,20 +49,26 @@ class Embed extends BlockType
...
@@ -49,20 +49,26 @@ class Embed extends BlockType
$payload
=
$this
->
decodePayloadString
(
$this
->
block
[
'payload'
]);
$payload
=
$this
->
decodePayloadString
(
$this
->
block
[
'payload'
]);
$oembedRequest
=
$this
->
buildOembedRequest
(
$payload
[
'source'
],
$payload
[
'url'
]);
$oembedRequest
=
$this
->
buildOembedRequest
(
$payload
[
'source'
],
$payload
[
'url'
]);
$payload
[
'oembed_request'
]
=
$oembedRequest
;
$payload
[
'oembed-request'
]
=
$oembedRequest
;
$payload
[
'oembed-unauthorized'
]
=
false
;
$payload
[
'oembed-unauthorized'
]
=
false
;
$payload
[
'oembed-not-found'
]
=
false
;
$payload
[
'oembed-not-found'
]
=
true
;
$payload
[
'oembed'
]
=
''
;
$payload
[
'oembed'
]
=
null
;
$payload
[
'request'
]
=
''
;
$payload
[
'request'
]
=
null
;
$request
=
\FileManager
::
fetchURLMetadata
(
$oembedRequest
);
if
(
$request
[
'response_code'
]
===
200
)
{
if
(
$oembedRequest
)
{
$payload
[
'request'
]
=
file_get_contents
(
$oembedRequest
,
false
,
get_default_http_stream_context
(
$oembedRequest
));
$request
=
\FileManager
::
fetchURLMetadata
(
$oembedRequest
);
$payload
[
'oembed'
]
=
json_decode
(
$payload
[
'request'
]);
if
(
$request
[
'response_code'
]
===
200
)
{
}
elseif
(
$request
[
'response_code'
]
===
401
)
{
$payload
[
'request'
]
=
file_get_contents
(
$oembedRequest
,
false
,
get_default_http_stream_context
(
$oembedRequest
));
$payload
[
'oembed_unauthorized'
]
=
true
;
$payload
[
'oembed'
]
=
json_decode
(
$payload
[
'request'
]);
}
else
{
$payload
[
'oembed-not-found'
]
=
false
;
$payload
[
'oembed_not_found'
]
=
true
;
}
if
(
$request
[
'response_code'
]
===
401
)
{
$payload
[
'oembed-unauthorized'
]
=
true
;
$payload
[
'oembed-not-found'
]
=
false
;
}
}
}
return
$payload
;
return
$payload
;
}
}
...
@@ -89,7 +95,7 @@ class Embed extends BlockType
...
@@ -89,7 +95,7 @@ class Embed extends BlockType
'youtube'
=>
'https://www.youtube.com/oembed'
,
'youtube'
=>
'https://www.youtube.com/oembed'
,
];
];
return
$endPoints
[
$source
]
.
'?url='
.
rawurlencode
(
$url
)
.
'&format=json'
;
return
array_key_exists
(
$source
,
$endPoints
)
?
$endPoints
[
$source
]
.
'?url='
.
rawurlencode
(
$url
)
.
'&format=json'
:
null
;
}
}
public
static
function
getCategories
():
array
public
static
function
getCategories
():
array
...
...
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