[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Remove double slash in PDF.js vendor paths.

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <690cfcd6ab7d2_2c6c950887623@gitlab-sidekiq-low-urgency-cpu-bound-v2-6b468b55d6-fwrtf.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
2cbbd952 by Joseph Ushindi at 2025-11-06T19:45:29+00:00
[FIX] Remove double slash in PDF.js vendor paths.
---
* [FIX] Remove double slash in PDF.js vendor paths.

See merge request tikiwiki/tiki!8972

- - - - -


4 changed files:

- lib/core/File/FileHelper.php
- lib/core/Tiki/Package/VendorHelper.php
- lib/prefs/fgal.php
- lib/wiki-plugins/wikiplugin_mediaplayer.php


Changes:

=====================================
lib/core/File/FileHelper.php
=====================================
@@ -71,7 +71,7 @@ class FileHelper
                 $errorMessageToAppend = 'Previous npm-asset/pdfjs-dist package has been deprecated.<br/>';
             }
 
-            $vendorPath = VendorHelper::getAvailableVendorPath('pdfjsviewer', '/npm-asset/pdfjs-dist-viewer-min/build/minified/build/pdf.js', false);
+            $vendorPath = VendorHelper::getAvailableVendorPath('pdfjsviewer', 'npm-asset/pdfjs-dist-viewer-min/build/minified/build/pdf.js', false);
             if (! file_exists($vendorPath)) {
                 $accesslib->display_error('tiki-display.php', tr($errorMessageToAppend . 'To view PDF files Tiki needs the npm-asset/pdfjs-dist-viewer-min. If you do not have permission to install this package, ask the site administrator.'));
             }
@@ -101,7 +101,7 @@ class FileHelper
             if (empty($sourceLink)) {
                 $accesslib->display_error('', tr('Invalid request'));
             } else {
-                $htmlViewFile = $vendorPath . '/npm-asset/pdfjs-dist-viewer-min/build/minified/web/viewer.html?file=';
+                $htmlViewFile = $vendorPath . 'npm-asset/pdfjs-dist-viewer-min/build/minified/web/viewer.html?file=';
                 // smarty_modifier_sefurl return &amp; that is already encoded, revert so when url is encoded, it works.
                 $sourceLink = preg_replace('/amp;/', '', $sourceLink);
                 $sourceLink = $htmlViewFile . urlencode(TikiLib::lib('access')->absoluteUrl($sourceLink));


=====================================
lib/core/Tiki/Package/VendorHelper.php
=====================================
@@ -34,6 +34,7 @@ class VendorHelper
      */
     public static function getAvailableVendorPath($packageName, $path, $fullPath = true)
     {
+        $path = ltrim($path, '/');
         foreach (self::AVAILABLE_VENDOR_PATHS as $pathPrefix) {
             $pathPrefix = str_replace(self::REPLACEABLE_PACKAGE_NAME_KEYWORD, $packageName, $pathPrefix);
             $filePath = $pathPrefix . $path;


=====================================
lib/prefs/fgal.php
=====================================
@@ -391,7 +391,7 @@ When the limit is reached, no more files can be uploaded. The user will see an e
             'type' => 'flag',
             'default' => 'n',
             'help' => 'PDF.js-viewer',
-            'packages_required' => ['npm-asset/pdfjs-dist-viewer-min' => VendorHelper::getAvailableVendorPath('pdfjsviewer', '/npm-asset/pdfjs-dist-viewer-min/build/minified/build/pdf.js')],
+            'packages_required' => ['npm-asset/pdfjs-dist-viewer-min' => VendorHelper::getAvailableVendorPath('pdfjsviewer', 'npm-asset/pdfjs-dist-viewer-min/build/minified/build/pdf.js')],
         ],
         'fgal_default_view' => [
             'name' => tra('Default view'),


=====================================
lib/wiki-plugins/wikiplugin_mediaplayer.php
=====================================
@@ -210,11 +210,11 @@ function wikiplugin_mediaplayer($data, $params)
             $url = $access->absoluteUrl($params['src']);
             $smarty->assign('url', $url);
             $smarty->assign('mediaplayerId', $iMEDIAPLAYER);
-            $oldPdfJsFile = VendorHelper::getAvailableVendorPath('pdfjs', '/npm-asset/pdfjs-dist/build/pdf.js');
+            $oldPdfJsFile = VendorHelper::getAvailableVendorPath('pdfjs', 'npm-asset/pdfjs-dist/build/pdf.js');
             $oldPdfJsFileAvailable = file_exists($oldPdfJsFile);
             $smarty->assign('oldPdfJsFileAvailable', $oldPdfJsFileAvailable);
 
-            $pdfJsfile = VendorHelper::getAvailableVendorPath('pdfjsviewer', '/npm-asset/pdfjs-dist-viewer-min/build/minified/build/pdf.js');
+            $pdfJsfile = VendorHelper::getAvailableVendorPath('pdfjsviewer', 'npm-asset/pdfjs-dist-viewer-min/build/minified/build/pdf.js');
             $pdfJsAvailable = file_exists($pdfJsfile);
             $smarty->assign('pdfJsAvailable', $pdfJsAvailable);
 
@@ -287,7 +287,7 @@ function wikiplugin_mediaplayer($data, $params)
             }
 
             if (! empty($sourceLink)) {
-                $htmlViewFile = VendorHelper::getAvailableVendorPath('pdfjsviewer', '/npm-asset/pdfjs-dist-viewer-min/build/minified/web/viewer.html') . '?file=';
+                $htmlViewFile = VendorHelper::getAvailableVendorPath('pdfjsviewer', 'npm-asset/pdfjs-dist-viewer-min/build/minified/web/viewer.html') . '?file=';
                 $sourceLink = $htmlViewFile . urlencode($access->absoluteUrl($sourceLink));
             }
 



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2cbbd952d387a45e732ab216599f6f19ae7eecdc

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2cbbd952d387a45e732ab216599f6f19ae7eecdc
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.