Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Camo Image Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
WP Plugins
Camo Image Proxy
Merge requests
!4
WIP: Initial release
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
WIP: Initial release
develop
into
master
Overview
0
Commits
18
Pipelines
29
Changes
1
Merged
Erick Hitter
requested to merge
develop
into
master
6 years ago
Overview
0
Commits
18
Pipelines
29
Changes
1
Expand
Fixes
#1
0
0
Merge request reports
Viewing commit
497ef3bf
Prev
Next
Show latest version
1 file
+
26
−
1
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
497ef3bf
Conditional to confirm we can rewrite
· 497ef3bf
Erick Hitter
authored
7 years ago
inc/functions.php
+
26
−
1
Options
@@ -12,6 +12,31 @@ namespace Camo_Image_Proxy;
@@ -12,6 +12,31 @@ namespace Camo_Image_Proxy;
*
*
* @return object
* @return object
*/
*/
function
Options
()
{
function
Options
()
{
// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid, Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
return
Options
::
instance
();
return
Options
::
instance
();
}
}
/**
* Can URLs be rewritten to use Camo?
*
* @return bool
*/
function
can_rewrite
()
:
bool
{
$host
=
Options
()
->
get
(
'host'
);
$key
=
Options
()
->
get
(
'key'
);
$can_rewrite
=
true
;
// Validate host.
if
(
empty
(
$host
)
||
(
!
filter_var
(
$host
,
FILTER_VALIDATE_URL
)
&&
!
filter_var
(
$host
,
FILTER_VALIDATE_IP
)
)
)
{
$can_rewrite
=
false
;
}
// Validate key.
// TODO: make sure it's an HMAC or something?
if
(
empty
(
$key
)
||
!
is_string
(
$key
)
)
{
$can_rewrite
=
false
;
}
return
apply_filters
(
'camo_image_proxy_can_rewrite'
,
$can_rewrite
,
$host
,
$key
);
}
Loading