Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
app
Commits
2a210685
Commit
2a210685
authored
Feb 09, 2021
by
Bertrand Gauthier
Browse files
Correction de Util::truncatedString boguée
parent
a668402e
Pipeline
#9122
failed with stages
in 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/UnicaenApp/Util.php
View file @
2a210685
...
...
@@ -338,11 +338,20 @@ class Util
if
(
strlen
(
$string
)
<=
$length
)
{
return
$string
;
}
$trunc
=
substr
(
$string
,
0
,
$length
);
if
(
$string
[
$length
]
===
' '
)
{
return
substr
(
$string
,
0
,
$length
)
.
$appended
;
$kept
=
$trunc
;
}
else
{
$found
=
strrpos
(
$trunc
,
' '
);
// position du dernier espace
if
(
$found
===
false
)
{
$kept
=
$trunc
;
}
else
{
$kept
=
substr
(
$string
,
0
,
$found
);
// on tronque à l'espace trouvé
}
}
return
substr
(
$string
,
0
,
strrpos
(
substr
(
$string
,
0
,
$length
),
' '
))
.
$appended
;
return
$kept
.
$appended
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment