Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory
Commits
fb35a648
Verified
Commit
fb35a648
authored
3 weeks ago
by
dockx thibault
Browse files
Options
Download
Patches
Plain Diff
(filter) - modify filtering logic
Adapts filtering to php8.2
parent
9124ca2c
core-php8
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class_ldapFilter.inc
+31
-13
include/class_ldapFilter.inc
with
31 additions
and
13 deletions
+31
-13
include/class_ldapFilter.inc
+
31
−
13
View file @
fb35a648
...
@@ -138,34 +138,52 @@ class ldapFilterLeaf extends ldapFilter implements \Stringable
...
@@ -138,34 +138,52 @@ class ldapFilterLeaf extends ldapFilter implements \Stringable
protected
$pattern
;
protected
$pattern
;
protected
$dnFilter
=
FALSE
;
protected
$dnFilter
=
FALSE
;
function
__construct
(
$left
,
$operator
,
$right
)
function
__construct
(
$left
,
$operator
,
$right
)
{
{
if
(
@
strrpos
((
string
)
$left
,
':dn:'
,
-
4
)
!==
FALSE
)
{
// Ensure $left is a string for consistency
$this
->
dnFilter
=
TRUE
;
$left
=
(
string
)
$left
;
$left
=
substr
((
string
)
$left
,
0
,
-
4
);
// Check if $left ends with ':dn:' using str_ends_with()
if
(
str_ends_with
(
$left
,
':dn:'
))
{
$this
->
dnFilter
=
true
;
$left
=
substr
(
$left
,
0
,
-
4
);
// Remove ':dn:'
}
}
parent
::
__construct
(
$operator
,
[
$left
,
$right
]);
parent
::
__construct
(
$operator
,
[
$left
,
$right
]);
if
((
$this
->
operator
==
'='
)
||
(
$this
->
operator
==
'~='
))
{
if
(
$this
->
operator
===
'='
||
$this
->
operator
===
'~='
)
{
$prefix
=
''
;
$prefix
=
''
;
$suffix
=
''
;
$suffix
=
''
;
if
(
preg_match
(
'/^\\*/'
,
(
string
)
$this
->
subparts
[
1
]))
{
// Detect * at start and end using a single regex
if
(
preg_match
(
'/^\*(.*)\*$/'
,
(
string
)
$this
->
subparts
[
1
],
$matches
))
{
$prefix
=
'.*'
;
$prefix
=
'.*'
;
}
if
(
preg_match
(
'/\\*$/'
,
(
string
)
$this
->
subparts
[
1
]))
{
$suffix
=
'.*'
;
$suffix
=
'.*'
;
$search
=
$matches
[
1
];
// Extract inner content
}
else
{
$search
=
trim
((
string
)
$this
->
subparts
[
1
],
'*'
);
if
(
str_starts_with
((
string
)
$this
->
subparts
[
1
],
'*'
))
{
$prefix
=
'.*'
;
}
if
(
str_ends_with
((
string
)
$this
->
subparts
[
1
],
'*'
))
{
$suffix
=
'.*'
;
}
}
}
$search
=
preg_replace
([
'/^\\*/'
,
'/\\*$/'
],
''
,
(
string
)
$this
->
subparts
[
1
]);
$escapedSearch
=
preg_quote
(
$search
,
'/'
);
// Construct the pattern
if
(
$this
->
dnFilter
)
{
if
(
$this
->
dnFilter
)
{
$this
->
pattern
=
'/'
.
$left
.
'='
.
$prefix
.
preg_quote
((
string
)
$search
,
'/'
)
.
$suffix
.
'
,/
'
;
$this
->
pattern
=
"/
{
$left
}
=
{
$prefix
}{
$escapedSearch
}{
$suffix
}
,/
"
;
}
elseif
(
$this
->
subparts
[
1
]
==
'*'
)
{
}
elseif
(
$this
->
subparts
[
1
]
==
=
'*'
)
{
$this
->
pattern
=
'/^.*$/'
;
$this
->
pattern
=
'/^.*$/'
;
}
else
{
}
else
{
$this
->
pattern
=
'
/^
'
.
$prefix
.
preg_quote
((
string
)
$search
,
'/'
)
.
$suffix
.
'
$/
'
;
$this
->
pattern
=
"
/^
{
$prefix
}{
$escapedSearch
}{
$suffix
}
$/
"
;
}
}
}
}
}
}
function
isDnFilter
()
function
isDnFilter
()
{
{
return
$this
->
dnFilter
;
return
$this
->
dnFilter
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets