From 9e5284a60f39a9fc764422a03d6522eeabff23a8 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 10 Dec 2016 17:13:25 +0100 Subject: =?UTF-8?q?Bugfix=20:=20strpos()=20avec=20un=20offset=20qui=20peut?= =?UTF-8?q?=20=C3=AAtre=20hors=20chaine.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Thu Dec 08 14:13:18.245825 2016] [:error] [pid 10306] [client 185.61.116.41:48834] PHP Warning: strpos(): Offset not contained in string in /root/chd_gestion/api/img_adt_svc_relais.php on line 94 --- api/img_adt_svc_relais.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/img_adt_svc_relais.php b/api/img_adt_svc_relais.php index d62145c..18abebe 100644 --- a/api/img_adt_svc_relais.php +++ b/api/img_adt_svc_relais.php @@ -90,10 +90,13 @@ EOD; function node_adt($adherent_id, $shape, $adt, $adt_title) { $adt_title = htmlentities($adt_title); + $adt_title_len = strlen($adt_title); foreach ( [ 10, 30 ] as $limit ) { - $breakpos = strpos($adt_title, ' ', $limit); - if ( $breakpos !== FALSE ) { - $adt_title = substr($adt_title, 0, $breakpos) . '
' . substr($adt_title, $breakpos); + if ( $adt_title_len > $limit ) { + $breakpos = strpos($adt_title, ' ', $limit); + if ( $breakpos !== FALSE ) { + $adt_title = substr($adt_title, 0, $breakpos) . '
' . substr($adt_title, $breakpos); + } } } return <<