Bitcoin Forum
May 04, 2024, 12:40:49 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Topic title RTL weirdness (SMF patch)  (Read 181 times)
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 510
Merit: 4001



View Profile
October 02, 2023, 03:10:32 PM
Last edit: October 06, 2023, 05:59:33 AM by PowerGlove
Merited by hugeblack (10), ABCbits (8), Foxpup (6), dkbit98 (5), joker_josue (5), Halab (2), DdmrDdmr (1)
 #1

This is a fix for an old issue that Foxpup diagnosed:

The cause is that Arabic text automatically switches the text direction to right-to-left, and since the immediately following text is just numbers and punctuation marks, which can written in either direction, there's nothing to change it back.

Mods can fix it in this instance by adding a left-to-right mark (U+200E, ‎) to the end of the thread title, though that doesn't address the underlying bug.

Basically, topic titles ending with certain characters will cause the page numbers to mis-render, like this:



It's easy to find many examples of this on the Arabic and Hebrew local boards, like the following:



With this patch, the two previous examples would render like so:





Here's the diff for @theymos:

Code:
--- baseline/Sources/MessageIndex.php	2011-12-22 22:56:39.000000000 +0000
+++ modified/Sources/MessageIndex.php 2023-10-02 14:44:40.000000000 +0000
@@ -495,32 +495,32 @@
 
  // Decide how many pages the topic should have.
  $topic_length = $row['numReplies'] + 1;
  if ($topic_length > $modSettings['defaultMaxMessages'])
  {
  $tmppages = array();
  $tmpa = 1;
  for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
  {
  $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . '">' . $tmpa . '</a>';
  $tmpa++;
  }
  // Show links to all the pages?
  if (count($tmppages) <= 5)
- $pages = '&#171; ' . implode(' ', $tmppages);
+ $pages = '&lrm;&#171; ' . implode(' ', $tmppages);
  // Or skip a few?
  else
- $pages = '&#171; ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];
+ $pages = '&lrm;&#171; ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];
 
  if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
  $pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
  $pages .= ' &#187;';
  }
  else
  $pages = '';
 
  // We need to check the topic icons exist...
  if (empty($modSettings['messageIconChecks_disable']))
  {
  if (!isset($context['icon_sources'][$row['firstIcon']]))
  $context['icon_sources'][$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
  if (!isset($context['icon_sources'][$row['lastIcon']]))

Edit: Adding a second diff because I noticed that this issue also shows up on ?action=unread, ?action=unreadreplies and ?action=watchlist.

Code:
--- baseline/Sources/Recent.php	2011-02-07 16:45:09.000000000 +0000
+++ modified/Sources/Recent.php 2023-10-06 04:52:26.000000000 +0000
@@ -981,32 +981,32 @@
 
  // Decide how many pages the topic should have.
  $topic_length = $row['numReplies'] + 1;
  if ($topic_length > $modSettings['defaultMaxMessages'])
  {
  $tmppages = array();
  $tmpa = 1;
  for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
  {
  $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
  $tmpa++;
  }
  // Show links to all the pages?
  if (count($tmppages) <= 5)
- $pages = '&#171; ' . implode(' ', $tmppages);
+ $pages = '&lrm;&#171; ' . implode(' ', $tmppages);
  // Or skip a few?
  else
- $pages = '&#171; ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];
+ $pages = '&lrm;&#171; ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];
 
  if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
  $pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
  $pages .= ' &#187;';
  }
  else
  $pages = '';
 
  // We need to check the topic icons exist... you can never be too sure!
  if (empty($modSettings['messageIconChecks_disable']))
  {
  // First icon first... as you'd expect.
  if (!isset($context['icon_sources'][$row['firstIcon']]))
  $context['icon_sources'][$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
"I'm sure that in 20 years there will either be very large transaction volume or no volume." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714783249
Hero Member
*
Offline Offline

Posts: 1714783249

View Profile Personal Message (Offline)

Ignore
1714783249
Reply with quote  #2

1714783249
Report to moderator
digaran
Copper Member
Hero Member
*****
Offline Offline

Activity: 1330
Merit: 899

🖤😏


View Profile
October 02, 2023, 05:39:09 PM
 #2

This seems to be the case on local boards and not other languages board, why do you think that is?

🖤😏
hg_away
Member
**
Offline Offline

Activity: 111
Merit: 69

Alt of @hugeblack


View Profile
October 02, 2023, 06:39:27 PM
 #3

This seems to be the case on local boards and not other languages board, why do you think that is?
It almost applies to languages that are written from right to left, such as Arabic and Hebrew. It is an update that has been awaited for almost several years, so I hope that the patch will be implemented.

E-mail me at  hugeblack_whitelist@protonmail.com if you want to be whitelisted
digaran
Copper Member
Hero Member
*****
Offline Offline

Activity: 1330
Merit: 899

🖤😏


View Profile
October 02, 2023, 08:48:44 PM
 #4

This seems to be the case on local boards and not other languages board, why do you think that is?
It almost applies to languages that are written from right to left, such as Arabic and Hebrew. It is an update that has been awaited for almost several years, so I hope that the patch will be implemented.
I just checked and it seems to show like that for some cases, example is  persian thread in other languages which is Ok, and when you read the last post on other topics,  this bug shows when there are no new posts, [new] seems to fix the bug temporarily.

🖤😏
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 510
Merit: 4001



View Profile
October 03, 2023, 06:30:07 PM
 #5

This seems to be the case on local boards and not other languages board, why do you think that is?
This is an issue on that board, too. Here's an (Urdu, I think) example:



If you read the OP carefully (particularly Foxpup's quote) then you'll understand this issue better. Some Unicode characters are meant to be laid out right-to-left instead of left-to-right, and sometimes topic titles end with character sequences that leave the text direction flipped, which then messes up the way the page links are rendered. What this patch does is make sure that the text direction is always set to left-to-right before the page links get emitted.

(...) this bug shows when there are no new posts, [new] seems to fix the bug temporarily.
Hmm, I don't think that's the case (though, maybe I misunderstand you). Here's the previous example with the "new" button in effect, and the bug presents the same way:

digaran
Copper Member
Hero Member
*****
Offline Offline

Activity: 1330
Merit: 899

🖤😏


View Profile
October 03, 2023, 08:23:56 PM
 #6

Your screenshots differ from mine, look :






🖤😏
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 510
Merit: 4001



View Profile
October 03, 2023, 11:38:19 PM
 #7

Your screenshots differ from mine (...)
I see. I'm not sure why your button is textual and mine is graphical (maybe it's a mobile vs. desktop thing, or a BPIP vs. vanilla thing), but if you understood my previous response (and carefully read Foxpup's quote in the OP), then I'm sure you can appreciate why putting the text "[new]" between the topic title and the page links will flip the text direction back to left-to-right. It's kind of interesting, but doesn't really have any bearing on this patch, so I don't think it's a tangent that justifies further discussion.
yhiaali3
Legendary
*
Offline Offline

Activity: 1694
Merit: 1857


#SWGT CERTIK Audited


View Profile WWW
October 04, 2023, 04:45:28 AM
Merited by PowerGlove (2), dkbit98 (1)
 #8

Good news for the Arabic section and sections that write from right to left, this is a really annoying old problem.

I do not know if this update will solve the other problem, which is the inability of the title to read the entire Arabic text if the number of characters is greater than a certain number. This can be seen in this example:

This is a screenshot of the notification email with a new topic title as it appears fully in the message:

                                    

While the title does not appear in full on the main Arabic section page:

                                    

Can this problem be solved with this update?

PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 510
Merit: 4001



View Profile
October 04, 2023, 08:34:58 AM
Merited by yhiaali3 (1)
 #9

Can this problem be solved with this update?
Unfortunately, this patch won't fix the issue you're talking about. Thanks for bringing it to my attention, though! (I appreciate learning about forum problems that I'm unlikely to bump into on my own.)

I'll add it to my backlog and see what I can do about it in the future. Wink
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!