Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly show the file tree if the widget is restricted to a path #7180

Open
wants to merge 3 commits into
base: 4.13
Choose a base branch
from

Conversation

leofeyer
Copy link
Member

@leofeyer leofeyer commented May 3, 2024

Fixes #6412

@zonky2 Can you please check if the changes solve your problem?

@leofeyer leofeyer added the bug label May 3, 2024
@leofeyer leofeyer added this to the 4.13 milestone May 3, 2024
@leofeyer leofeyer self-assigned this May 3, 2024
@leofeyer leofeyer requested a review from a team May 3, 2024 09:55
@leofeyer leofeyer linked an issue May 3, 2024 that may be closed by this pull request
@zonky2
Copy link
Contributor

zonky2 commented May 3, 2024

@leofeyer

The problem is solved by the fix so far...

However, the breadcrumb is not displayed in the popup - but I think that's better for usability. The breadcrumb only appears in the popup if I have clicked on a folder there or I accidentally clicked on exactly the same folder in the file manager.

@leofeyer
Copy link
Member Author

leofeyer commented May 8, 2024

That is intended (see #6412 (comment)).

@zonky2
Copy link
Contributor

zonky2 commented May 8, 2024

Die Anzeige der Breadcrumb sollte man nochmal überdenken. Mit der jetzigen Implementierung erscheint die Breadcrumb im Popup nicht - außer ich habe vorher im Dateimanager zufällig den selben Pfad angeklickt, klicke den selben Pfad im Popup an oder einen Pfad innerhalb meiner (Vor-)Auswahl.

Die Angabe des Pfades soll ja lediglich eine Hilfe sein, im richtigen Ordner zu landen und keine Restriktion auf einen Ordnerzugriff. Wenn man als Vorauswahl content/images/ angegeben hat und im Popup die Breadcrumb erscheint, kann man darüber nicht in einen höher gelegegenen Ordner wie content/ wechseln - verwendet man die Bildersuche, kommt man auch in höher gelegene Ordner.

... aber wenn das mit der Breadcrumb so sein soll - warum auch immer (??!) - dann bitte die Sachen so übernehmen.

@fritzmg
Copy link
Contributor

fritzmg commented May 8, 2024

Die Angabe des Pfades soll ja lediglich eine Hilfe sein, im richtigen Ordner zu landen und keine Restriktion auf einen Ordnerzugriff.

I don't think that's actually the case. This is a feature of the old and deprecated FileSelector and there it was always intended as a restriction - not just a default filter. In fact, it is even prioritized over the file mounts:

// Respect existing limitations
if ($this->path)
{
while ($objRoot->next())
{
if (strncmp($this->path . '/', $objRoot->path . '/', \strlen($this->path) + 1) === 0)
{
if ($objRoot->type == 'folder' || empty($this->arrValidFileTypes) || \in_array($objRoot->extension, $this->arrValidFileTypes))
{
$arrFound[] = $objRoot->path;
}
$arrPaths[] = ($objRoot->type == 'folder') ? $objRoot->path : \dirname($objRoot->path);
}
}
}
elseif ($this->User->isAdmin)
{
// Show all files to admins
while ($objRoot->next())
{
if ($objRoot->type == 'folder' || empty($this->arrValidFileTypes) || \in_array($objRoot->extension, $this->arrValidFileTypes))
{
$arrFound[] = $objRoot->path;
}
$arrPaths[] = ($objRoot->type == 'folder') ? $objRoot->path : \dirname($objRoot->path);
}
}
elseif (\is_array($this->User->filemounts))
{
while ($objRoot->next())
{
// Show only mounted folders to regular users
foreach ($this->User->filemounts as $path)
{
if (strncmp($path . '/', $objRoot->path . '/', \strlen($path) + 1) === 0)
{
if ($objRoot->type == 'folder' || empty($this->arrValidFileTypes) || \in_array($objRoot->extension, $this->arrValidFileTypes))
{
$arrFound[] = $objRoot->path;
}
$arrPaths[] = ($objRoot->type == 'folder') ? $objRoot->path : \dirname($objRoot->path);
}
}
}
}
$GLOBALS['TL_DCA']['tl_files']['list']['sorting']['root'] = array_unique($arrPaths);

@leofeyer
Copy link
Member Author

Die Angabe des Pfades soll ja lediglich eine Hilfe sein, im richtigen Ordner zu landen und keine Restriktion auf einen Ordnerzugriff. Wenn man als Vorauswahl content/images/ angegeben hat und im Popup die Breadcrumb erscheint, kann man darüber nicht in einen höher gelegegenen Ordner wie content/ wechseln - verwendet man die Bildersuche, kommt man auch in höher gelegene Ordner.

Wenn eval.path gesetzt ist, soll der Zugriff definitiv auf diesen Ordner begrenzt sein. Was genau meinst Du mit über die "Bildersuche kommt man auch in höher gelegene Ordner"?

@zonky2
Copy link
Contributor

zonky2 commented May 24, 2024

Was genau meinst Du mit über die "Bildersuche kommt man auch in höher gelegene Ordner"?

genau das was isch geschrieben habe... wenn der Pfad z.B. auf content/images/ gesetzt ist und ich suche nach "logo.png" was sich in theme/images/ befindet, wird das als Ergebnis/Fundstelle angezeigt

@leofeyer
Copy link
Member Author

Wir haben das gerade kurz diskutiert und sind der Meinung, dass eval.path dazu gedacht ist, den Picker auf einen bestimmten Pfad zu beschränken. Das ist auch so im Handbuch dokumentiert:

Es handelt sich um ein "custom root directory" und nicht um eine Vorauswahl für das Breadcrumb-Menü, also ist die Implementierung in diesem PR korrekt.

Es ist aber ein Bug, dass man über die Suche aus dem festgelegten Pfad ausbrechen kann. (Nur ein Bug und keine Sicherheitslücke, da eval.path niemals ein nicht-gemounteter Ordner sein kann und der Benutzer ja sowieso alle gemounteten Dateien in der Dateiverwaltung sieht.)

@leofeyer
Copy link
Member Author

leofeyer commented May 28, 2024

Fixed in 31a0ecf. Probably best viewed without whitespace changes.

@leofeyer leofeyer requested review from ausi and removed request for a team May 28, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error with eval 'path' in file picker
3 participants