From 094ff956b80b82d1053aab107bf068e8ccf59ec5 Mon Sep 17 00:00:00 2001 From: Michiel Dethmers Date: Mon, 1 May 2023 09:50:47 +0100 Subject: [PATCH] Use element instead of zero-width space character to allow wrapping of an email address or URL (#952) Co-authored-by: Duncan Cameron --- public_html/lists/admin/lib.php | 29 +++++++-- public_html/lists/admin/mclicks.php | 2 +- public_html/lists/admin/members.php | 86 +++++++++++++------------- public_html/lists/admin/mviews.php | 74 +++++++++++----------- public_html/lists/admin/uclicks.php | 2 +- public_html/lists/admin/userclicks.php | 22 +++---- 6 files changed, 118 insertions(+), 97 deletions(-) diff --git a/public_html/lists/admin/lib.php b/public_html/lists/admin/lib.php index ee4704f84..0f20c577d 100644 --- a/public_html/lists/admin/lib.php +++ b/public_html/lists/admin/lib.php @@ -1971,15 +1971,36 @@ function shortenText($text, $max = 30) * mostly used for columns in listings to retrict the width, particularly on mobile devices * it will show the full text as the title tip but restrict the size of the output * - * will also place a space after / and @ to facilitate wrapping in the browser - * */ function shortenTextDisplay($text, $max = 30) +{ + $display = shortenText($text, $max); + + return sprintf('%s', htmlspecialchars($text), $display); +} +/* + * shortenEmailDisplay + * + * Similar to shortenTextDisplay() but adds a wbr element after @ to allow wrapping + */ +function shortenEmailDisplay($text, $max = 30) +{ + $display = shortenText($text, $max); + $display = str_replace('@', '@', $display); + + return sprintf('%s', htmlspecialchars($text), $display); +} + +/* + * shortenUrlDisplay + * + * Similar to shortenTextDisplay() but adds a wbr element after each / to allow wrapping + */ +function shortenUrlDisplay($text, $max = 30) { $display = preg_replace('!^https?://!i', '', $text); $display = shortenText($display, $max); - $display = str_replace('/', '/​', $display); - $display = str_replace('@', '@​', $display); + $display = str_replace('/', '/', $display); return sprintf('%s', htmlspecialchars($text), $display); } diff --git a/public_html/lists/admin/mclicks.php b/public_html/lists/admin/mclicks.php index a5bb62efb..d3444ce9a 100644 --- a/public_html/lists/admin/mclicks.php +++ b/public_html/lists/admin/mclicks.php @@ -140,7 +140,7 @@ ); if (!$download) { - $element = shortenTextDisplay($row['url']); + $element = shortenUrlDisplay($row['url']); } else { $element = $row['url']; } diff --git a/public_html/lists/admin/members.php b/public_html/lists/admin/members.php index cda73e84c..f5abae282 100644 --- a/public_html/lists/admin/members.php +++ b/public_html/lists/admin/members.php @@ -316,7 +316,7 @@ function addUserForm($listid) $ls = new WebblerListing($GLOBALS['I18N']->get('Members')); $ls->usePanel($paging); while ($user = Sql_fetch_array($result)) { - $element = shortenTextDisplay($user['email']); + $element = shortenEmailDisplay($user['email']); $ls->addElement($element, PageUrl2('user&id='.$user['id'])); $ls->setClass($element, 'row1'); $ls_delete = ''; @@ -364,14 +364,14 @@ function addUserForm($listid) ?>
-

-
-
-
-

get('What to do with "Tagged" users') ?>:

+

+
+
+
+

get('What to do with "Tagged" users') ?>:

get('This will only process the users in this page that have the "Tag" checkbox checked') ?>
-

get('Delete') ?> +

get('Delete') ?> (get('from this list') ?>)

@@ -385,26 +385,26 @@ function addUserForm($listid) } if ($html) { ?> -
-
- get('Move').' '.$GLOBALS['I18N']->get('to').':   ' ?> -
-
- get('Move').' '.$GLOBALS['I18N']->get('to').':   ' ?> +
+
+ -
+ +
-
-
- get('Copy').' '.$GLOBALS['I18N']->get('to').':  ' ?> -
-
- get('Copy').' '.$GLOBALS['I18N']->get('to').':  ' ?> +
+
+ -
-
+ +
+
get('Nothing') ?>
@@ -413,7 +413,7 @@ function addUserForm($listid)

-

+

get('Delete') ?> @@ -422,29 +422,29 @@ function addUserForm($listid)

-
-
- get('Move').' '.$GLOBALS['I18N']->get('to').':  ' ?> -
-
- get('Move').' '.$GLOBALS['I18N']->get('to').':  ' ?> +
+
+ -
+ +
-
-
- get('Copy').' '.$GLOBALS['I18N']->get('to').':  ' ?> -
-
- get('Copy').' '.$GLOBALS['I18N']->get('to').':  ' ?> +
+
+ -
+ +
- get('Nothing') ?> -
+ get('Nothing') ?> +
diff --git a/public_html/lists/admin/mviews.php b/public_html/lists/admin/mviews.php index 905d868ca..c8be050af 100644 --- a/public_html/lists/admin/mviews.php +++ b/public_html/lists/admin/mviews.php @@ -23,11 +23,11 @@ if ($id) { $allow = Sql_Fetch_Row_query( sprintf( - 'select - owner - from - %s - where + 'select + owner + from + %s + where id = %d %s' , $GLOBALS['tables']['message'] , $id @@ -78,11 +78,11 @@ //print '

'.s('View Details for a Message').'

'; $messagedata = Sql_Fetch_Array_query( - "SELECT - * - FROM - {$tables['message']} - WHERE + "SELECT + * + FROM + {$tables['message']} + WHERE id = $id $subselect" ); echo '
' . @@ -102,16 +102,16 @@ $req = Sql_Query( sprintf( - 'select + 'select um.userid - from + from %s um - , %s msg - where - um.messageid = %d - and um.messageid = msg.id + , %s msg + where + um.messageid = %d + and um.messageid = msg.id and um.viewed is not null %s - group by + group by userid' , $GLOBALS['tables']['usermessage'] , $GLOBALS['tables']['message'] @@ -150,7 +150,7 @@ $req = Sql_Query( sprintf( - 'select + 'select userid , email , um.entered as sent @@ -159,21 +159,21 @@ , count(um.viewed) as uniqueviews , msg.viewed as totalcampaignviews , abs(unix_timestamp(um.entered) - unix_timestamp(um.viewed)) as responsetime - from + from %s um , %s user - , %s msg - where - um.messageid = %d - and um.messageid = msg.id - and um.userid = user.id - and um.status = "sent" - and um.viewed is not null + , %s msg + where + um.messageid = %d + and um.messageid = msg.id + and um.userid = user.id + and um.status = "sent" + and um.viewed is not null %s - group by + group by userid order by - lastview desc + lastview desc %s' , $GLOBALS['tables']['usermessage'] , $GLOBALS['tables']['user'] @@ -189,14 +189,14 @@ $allViewsReq = Sql_Query( sprintf( - 'select - * - from - %s - where - userid = %d - and messageid = %d - order by + 'select + * + from + %s + where + userid = %d + and messageid = %d + order by viewed' , $GLOBALS['tables']['user_message_view'] , $row['userid'] @@ -209,7 +209,7 @@ $element = $row['email']; $separator = ','; } else { - $element = shortenTextDisplay($row['email'], 35); + $element = shortenEmailDisplay($row['email'], 35); $separator = '
'; } $ls->addElement($element, PageUrl2('user&id='.$row['userid'])); diff --git a/public_html/lists/admin/uclicks.php b/public_html/lists/admin/uclicks.php index c1d8e5342..8f4530a9e 100644 --- a/public_html/lists/admin/uclicks.php +++ b/public_html/lists/admin/uclicks.php @@ -57,7 +57,7 @@ while ($row = Sql_Fetch_Array($req)) { $some = 1; if (!$download) { - $element = shortenTextDisplay($row['url'], 30); + $element = shortenUrlDisplay($row['url'], 30); } else { $element = $row['url']; } diff --git a/public_html/lists/admin/userclicks.php b/public_html/lists/admin/userclicks.php index 969f86186..7b374f303 100644 --- a/public_html/lists/admin/userclicks.php +++ b/public_html/lists/admin/userclicks.php @@ -87,7 +87,7 @@ echo '
'.PageLinkButton('userclicks&fwdid='.$fwdid.'&msgid='.$msgid.'&dl=1', s('Download subscribers')).'
'; $query = sprintf('select htmlclicked, textclicked, user.email,user.id as userid,firstclick,latestclick,clicked - from %s as uml_click, %s as user where uml_click.userid = user.id + from %s as uml_click, %s as user where uml_click.userid = user.id and uml_click.forwardid = %d and uml_click.messageid = %d and uml_click.clicked', $GLOBALS['tables']['linktrack_uml_click'], $GLOBALS['tables']['user'], $fwdid, $msgid); } elseif ($userid && $msgid) { @@ -105,7 +105,7 @@
' .$GLOBALS['I18N']->get('Sent').''.$messagedata['sent'].'
'; $query = sprintf('select htmlclicked, textclicked,user.email,user.id as userid,firstclick,latestclick, - clicked,messageid,forwardid,url from %s as uml_click, %s as user, %s as forward where uml_click.userid = user.id + clicked,messageid,forwardid,url from %s as uml_click, %s as user, %s as forward where uml_click.userid = user.id and uml_click.userid = %d and uml_click.messageid = %d and forward.id = uml_click.forwardid', $GLOBALS['tables']['linktrack_uml_click'], $GLOBALS['tables']['user'], $GLOBALS['tables']['linktrack_forward'], $userid, $msgid); @@ -151,7 +151,7 @@ MAX(latestclick) AS latestclick, SUM(clicked) AS clicked FROM %s AS uml_click - JOIN %s AS user ON uml_click.userid = user.id + JOIN %s AS user ON uml_click.userid = user.id WHERE uml_click.messageid = %d GROUP BY uml_click.userid ', @@ -177,18 +177,18 @@ messageid SEPARATOR \' \') AS messageid, forwardid, url - FROM + FROM '.$GLOBALS['tables']['linktrack_uml_click'].' AS uml_click JOIN '.$GLOBALS['tables']['user'].' AS user ON uml_click.userid = user.id - JOIN + JOIN '.$GLOBALS['tables']['linktrack_forward'].' AS forward ON forward.id = uml_click.forwardid - WHERE + WHERE uml_click.userid = '.sprintf('%d', $userid).' - GROUP BY + GROUP BY forwardid - ORDER BY - clicked DESC, + ORDER BY + clicked DESC, url '; } @@ -214,13 +214,13 @@ $downloadContent .= $row['email'].PHP_EOL; } else { if (!$userid) { - $element = shortenTextDisplay($row['email']); + $element = shortenEmailDisplay($row['email']); $ls->addElement($element, PageUrl2('user&id='.$row['userid'])); $ls->setClass($element, 'row1'); } else { // $link = substr($row['url'],0,50); // $element = PageLink2($link,$link,PageUrl2('uclicks&id='.$row['forwardid']),"",true,$row['url']); - $element = shortenTextDisplay($row['url']); + $element = shortenUrlDisplay($row['url']); $ls->addElement($element, PageUrl2('uclicks&id='.$row['forwardid'])); $ls->setClass($element, 'row1'); $messageLinks = preg_replace_callback(