Index: typo3/sysext/core/Classes/Database/SoftReferenceIndex.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- typo3/sysext/core/Classes/Database/SoftReferenceIndex.php	(revision 479f34671ce267fa28157948648ddf98ee6fbd4f)
+++ typo3/sysext/core/Classes/Database/SoftReferenceIndex.php	(revision c107879e8e1eb79faf2493084fb9d0429cc92672)
@@ -269,6 +269,9 @@
                         $linkDetails = $linkService->resolve($matches[1]);
                         if ($linkDetails['type'] === LinkService::TYPE_FILE && preg_match('/file\?uid=(\d+)/', $matches[1], $fileIdMatch)) {
                             $token = $this->makeTokenID($key);
+                            // PATCH GAYA : ajout de matchString
+                            $elements[$key]['matchString'] = $linkTags[$key];
+                            // FIN PATCH GAYA
                             $linkTags[$key] = str_replace($matches[1], '{softref:' . $token . '}', $linkTags[$key]);
                             $elements[$key]['subst'] = [
                                 'type' => 'db',
@@ -277,16 +280,42 @@
                                 'tokenValue' => 'file:' . ($linkDetails['file'] instanceof File ? $linkDetails['file']->getUid() : $fileIdMatch[1])
                             ];
                         } elseif ($linkDetails['type'] === LinkService::TYPE_PAGE && preg_match('/page\?uid=(\d+)#?(\d+)?/', $matches[1], $pageAndAnchorMatches)) {
+                            // PATCH GAYA : ajout de matchString et prise en charge des ancres corrigées
                             $token = $this->makeTokenID($key);
-                            $linkTags[$key] = str_replace($matches[1], '{softref:' . $token . '}', $linkTags[$key]);
+                            $content = '{softref:' . $token . '}';
+                            $elements[$key]['matchString'] = $linkTags[$key];
                             $elements[$key]['subst'] = [
                                 'type' => 'db',
-                                'recordRef' => 'pages:' . $linkDetails['pageuid'] . (isset($pageAndAnchorMatches[2]) ? '#c' . $pageAndAnchorMatches[2] : ''),
+                                'recordRef' => 'pages:' . $linkDetails['pageuid'],
                                 'tokenID' => $token,
-                                'tokenValue' => $linkDetails['pageuid'] . (isset($pageAndAnchorMatches[2]) ? '#c' . $pageAndAnchorMatches[2] : '')
+                                'tokenValue' => $linkDetails['pageuid']
                             ];
+                            if (isset($pageAndAnchorMatches[2]) && $pageAndAnchorMatches[2] !== '') {
+                                // Anchor is assumed to point to a content elements:
+                                if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($pageAndAnchorMatches[2])) {
+                                    // Initialize a new entry because we have a new relation:
+                                    $newTokenID = $this->makeTokenID('setTypoLinkPartsElement:anchor:' . $key);
+                                    $elements[$newTokenID . ':' . $key] = [];
+                                    $elements[$newTokenID . ':' . $key]['matchString'] = 'Anchor Content Element: ' . $pageAndAnchorMatches[2];
+                                    $content .= '#{softref:' . $newTokenID . '}';
+                                    $elements[$newTokenID . ':' . $key]['subst'] = [
+                                        'type' => 'db',
+                                        'recordRef' => 'tt_content:' . $pageAndAnchorMatches[2],
+                                        'tokenID' => $newTokenID,
+                                        'tokenValue' => $pageAndAnchorMatches[2]
+                                    ];
+                                } else {
+                                    // Anchor is a hardcoded string
+                                    $content .= '#' . $pageAndAnchorMatches[2];
+                                }
+                            }
+                            $linkTags[$key] = str_replace($matches[1], $content, $linkTags[$key]);
+                            // FIN PATCH GAYA
                         } elseif ($linkDetails['type'] === LinkService::TYPE_URL) {
                             $token = $this->makeTokenID($key);
+                            // PATCH GAYA : ajout de matchString
+                            $elements[$key]['matchString'] = $linkTags[$key];
+                            // FIN PATCH GAYA
                             $linkTags[$key] = str_replace($matches[1], '{softref:' . $token . '}', $linkTags[$key]);
                             $elements[$key]['subst'] = [
                                 'type' => 'external',
@@ -301,7 +330,10 @@
                     // keep the legacy code for now
                     $typolinkValue = preg_replace('/<LINK[[:space:]]+/i', '', substr($foundValue, 0, -1));
                     $tLP = $this->getTypoLinkParts($typolinkValue);
-                    $linkTags[$k] = '<LINK ' . $this->setTypoLinkPartsElement($tLP, $elements, $typolinkValue, $k) . '>';
+                    // PATCH GAYA
+                    //$linkTags[$k] = '<LINK ' . $this->setTypoLinkPartsElement($tLP, $elements, $typolinkValue, $k) . '>';
+                    $linkTags[$key] = '<LINK ' . $this->setTypoLinkPartsElement($tLP, $elements, $typolinkValue, $key) . '>';
+                    // FIN PATCH GAYA
                 }
             }
         }
@@ -461,6 +493,27 @@
             return $finalTagParts;
         }

+        // PATCH GAYA
+        // Prise en charge des liens t3:// vers les pages
+        // Sans cela, les softref vers les pages ne sont pas détectées !
+        $linkService = GeneralUtility::makeInstance(LinkService::class);
+        $linkDetails = $linkService->resolve($link_param);
+        if ($linkDetails['type'] === LinkService::TYPE_PAGE) {
+            $finalTagParts['LINK_TYPE'] = LinkService::TYPE_PAGE;
+            $finalTagParts['page_id'] = $linkDetails['pageuid'];
+            if (isset($linkDetails['pagealias'])) {
+                $finalTagParts['alias'] = $linkDetails['pagealias'];
+            }
+            if (isset($linkDetails['pagetype'])) {
+                $finalTagParts['type'] = $linkDetails['pagetype'];
+            }
+            if (isset($linkDetails['fragment'])) {
+                $finalTagParts['anchor'] = $linkDetails['fragment'];
+            }
+            return $finalTagParts;
+        }
+        // FIN PATCH GAYA
+
         if ($pU['scheme'] === 't3' && $pU['host'] === LinkService::TYPE_RECORD) {
             $finalTagParts['LINK_TYPE'] = LinkService::TYPE_RECORD;
             $finalTagParts['url'] = $link_param;
@@ -627,7 +680,10 @@
                         ];
                     } else {
                         // Anchor is a hardcoded string
-                        $content .= '#' . $tLP['type'];
+                        // PATCH GAYA
+                        //$content .= '#' . $tLP['type'];
+                        $content .= '#' . $tLP['anchor'];
+                        // FIN PATCH GAYA
                     }
                 }
                 break;
Index: typo3/sysext/impexp/Classes/Import.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- typo3/sysext/impexp/Classes/Import.php	(revision 479f34671ce267fa28157948648ddf98ee6fbd4f)
+++ typo3/sysext/impexp/Classes/Import.php	(revision c107879e8e1eb79faf2493084fb9d0429cc92672)
@@ -1421,6 +1421,11 @@
                                     $insertValue = $tokenKey . ':' . $insertValue;
                                 }
                             }
+                            // PATCH GAYA
+                            if ($tempTable === 'pages') {
+                                $insertValue = $this->fixLegacyLinkFormat($cfg['spKey'], $insertValue);
+                            }
+                            // FIN PATCH GAYA
                     }
             }
             // Finally, swap the soft reference token in tokenized content with the insert value:
@@ -1429,6 +1434,35 @@
         return $tokenizedContent;
     }

+    /**
+     * PATCH GAYA
+     * Retransforme les token softref en url de type t3://
+     *
+     * @param $spKey
+     * @param $content
+     * @return string
+     * @throws \TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException
+     */
+    private function fixLegacyLinkFormat($spKey, $content) {
+        switch ($spKey) {
+            case 'typolink':
+            case 'typolink_tag':
+                $tLService = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Service\TypoLinkCodecService::class);
+                /* @var \TYPO3\CMS\Core\LinkHandling\LinkService $linkService */
+                $linkService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\LinkHandling\LinkService::class);
+                $linkElement = explode(',', $content);
+                foreach ($linkElement as $k => $typolinkValue) {
+                    $tLP = $tLService->decode($typolinkValue);
+                    $linkDetails = $linkService->resolve($tLP['url']);
+                    $linkElement[$k] = $linkService->asString($linkDetails);
+                }
+                $content = implode(',', $linkElement);
+                break;
+        }
+
+        return $content;
+    }
+
     /**
      * Process a soft reference file
      *
