Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
optimizely
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
optimizely
Commits
7acec3e8
Commit
7acec3e8
authored
11 years ago
by
Darren Douglas Lee
Browse files
Options
Downloads
Patches
Plain Diff
Fixed path validation: _optimizely_valid_paths()
parent
988e7aea
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
optimizely.admin.inc
+36
-16
36 additions, 16 deletions
optimizely.admin.inc
with
36 additions
and
16 deletions
optimizely.admin.inc
+
36
−
16
View file @
7acec3e8
...
...
@@ -186,7 +186,6 @@ function optimizely_add_update_form_validate($form, &$form_state) {
// Confirm project_code is unique or the entered project code is also the account ID - SELECT the project title in prep for related form error message
$query
=
db_query
(
'SELECT project_title FROM {optimizely} WHERE
project_code = :project_code ORDER BY oid DESC'
,
array
(
':project_code'
=>
$form_state
[
'values'
][
'optimizely_project_code'
]));
$query_count
=
$query
->
rowCount
();
// Flag submission if existing entry is found with the same project code value AND it's not an SINGLE entry to replace the "default" entry.
...
...
@@ -617,7 +616,7 @@ function optimizely_ajax_enable() {
$target_include
=
$result
->
include
;
// Check that the paths are valid for the newly enabled project
$valid_paths
=
_optimizely_valid_paths
(
$target_path
_array
);
$valid_paths
=
_optimizely_valid_paths
(
$target_path
s
);
// Check to see if the enable project has path entries that will result in
// duplicates with other enable projects
...
...
@@ -842,25 +841,46 @@ function _optimizely_unique_paths($target_paths, $target_include = TRUE, $target
* @return
* boolean of TRUE if the paths are valid or a string of the path that failed.
*/
function
_optimizely_valid_paths
(
$
targe
t_paths
)
{
function
_optimizely_valid_paths
(
$
projec
t_paths
)
{
// Validate entered paths to confirm the paths exist on the website
foreach
(
$target_paths
as
$project_path
)
{
// Deal with wildcards
if
(
strpos
(
$project_path
,
'*'
)
!==
FALSE
)
{
$project_path
=
substr
(
$project_path
,
0
,
strpos
(
$project_path
,
'*'
));
}
// Skip validation if <front> is path value
if
(
strpos
(
$project_path
,
'<front>'
)
===
FALSE
)
{
// Test for valid path
$path_found
=
drupal_lookup_path
(
'source'
,
$project_path
);
if
(
!
$path_found
)
{
foreach
(
$project_paths
as
$project_path
)
{
// Check for site wide wildcard
if
(
strpos
(
$project_path
,
'*'
)
===
0
)
{
return
TRUE
;
}
// Path wildcards
elseif
(
strpos
(
$project_path
,
'*'
)
!==
FALSE
)
{
$project_wildpath
=
substr
(
$project_path
,
0
,
strpos
(
$project_path
,
'*'
)
-
1
);
// select * from url_alias where source like 'article%' or alias like 'article%';
// Look for entries in url_aias
$query
=
db_query
(
"SELECT * FROM
{
url_alias
}
WHERE
source LIKE :project_wildpath OR alias LIKE :project_wildpath"
,
array
(
':project_wildpath'
=>
$project_wildpath
.
'%'
));
$project_wildpath_match
=
$query
->
rowCount
();
// No matches found for wildcard path
if
(
!
$project_wildpath_match
)
{
return
$project_path
;
}
}
// Specific path
else
{
// Validation if path valid menu router entry, includes support for <front>
if
(
drupal_valid_path
(
$project_path
,
TRUE
)
===
FALSE
)
{
// Look for entry in url_alias table
if
(
drupal_lookup_path
(
'alias'
,
$project_path
)
===
FALSE
&&
drupal_lookup_path
(
'source'
,
$project_path
)
===
FALSE
)
{
return
$project_path
;
}
}
}
}
...
...
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