Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
bibliossimo
opacce
Commits
e9c5d1d0
Commit
e9c5d1d0
authored
Jan 25, 2018
by
Ghislain Loas
Browse files
hotline #70402 fix url when files and folders got special chars
parent
37965235
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
17 deletions
+31
-17
library/Class/FileManager.php
library/Class/FileManager.php
+5
-0
library/ZendAfi/Controller/Plugin/Manager/FileManager.php
library/ZendAfi/Controller/Plugin/Manager/FileManager.php
+2
-2
library/ZendAfi/View/Helper/Admin/FileManager/File.php
library/ZendAfi/View/Helper/Admin/FileManager/File.php
+1
-1
tests/application/modules/admin/controllers/FileManagerControllerTest.php
...n/modules/admin/controllers/FileManagerControllerTest.php
+23
-14
No files found.
library/Class/FileManager.php
View file @
e9c5d1d0
...
...
@@ -410,6 +410,11 @@ class Class_FileManager extends Class_Entity {
}
public
function
getUrl
()
{
return
urlencode
(
$this
->
getPath
());
}
public
function
getRealpath
()
{
return
$this
->
_attribs
[
'Realpath'
];
}
...
...
library/ZendAfi/Controller/Plugin/Manager/FileManager.php
View file @
e9c5d1d0
...
...
@@ -44,7 +44,7 @@ class ZendAfi_Controller_Plugin_Manager_FileManager extends ZendAfi_Controller_P
},
'label'
=>
$this
->
_
(
'Sélectionner "%s"'
,
$model
->
getName
()),
'anchorOptions'
=>
array_filter
([
'title'
=>
$this
->
_
(
'Sélectionner "%s"'
,
$model
->
getName
()),
'onclick'
=>
"$(this).selectItemForCKEditor('"
.
Class_Url
::
relative
(
str_replace
([
"'"
,
'"'
],
[
"\'"
,
'"
'
],
$model
->
getId
()))
.
"');"
])],
'onclick'
=>
"$(this).selectItemForCKEditor('"
.
Class_Url
::
relative
(
str_replace
([
"'"
,
'"'
],
[
'%27'
,
'%22
'
],
$model
->
getId
()))
.
"');"
])],
[
'url'
=>
[
'action'
=>
'create'
,
'into'
=>
$model
->
getId
()],
...
...
@@ -104,7 +104,7 @@ class ZendAfi_Controller_Plugin_Manager_FileManager extends ZendAfi_Controller_P
'data-popup'
=>
'true'
,
'class'
=>
$model
->
isWritable
()
?
null
:
'disabled'
])],
[
'url'
=>
$model
->
get
Path
(),
[
'url'
=>
$model
->
get
Url
(),
'icon'
=>
''
,
'caption'
=>
function
(
$model
)
{
if
(
$model
->
isFile
())
...
...
library/ZendAfi/View/Helper/Admin/FileManager/File.php
View file @
e9c5d1d0
...
...
@@ -50,7 +50,7 @@ class ZendAfi_View_Helper_Admin_FileManager_File extends ZendAfi_View_Helper_Bas
];
$dl
=
$this
->
_tag
(
'dl'
,
implode
(
array_filter
(
$dt
)));
$url
=
$this
->
view
->
absoluteUrl
(
$file
->
get
Path
(),
null
,
true
)
.
'?version='
.
time
();
// force reload image
$url
=
$this
->
view
->
absoluteUrl
(
$file
->
get
Url
(),
null
,
true
)
.
'?version='
.
time
();
// force reload image
$open_new_tab
=
(
$file
->
isFile
()
?
$this
->
view
->
tagAnchor
(
$url
,
...
...
tests/application/modules/admin/controllers/FileManagerControllerTest.php
View file @
e9c5d1d0
...
...
@@ -1004,7 +1004,7 @@ Class FileManagerControllerDispatchImageTest extends FileManagerControllerTestCa
/** @test */
public
function
downloadCaliforniaAnchorShouldBePresent
()
{
$this
->
assertXPathContentContains
(
'//div//a[contains(@href, "userfiles
/
california.jpg")]'
,
'Télécharger'
);
$this
->
assertXPathContentContains
(
'//div//a[contains(@href, "userfiles
%2F
california.jpg")]'
,
'Télécharger'
,
$this
->
_response
->
getBody
()
);
}
...
...
@@ -1067,7 +1067,7 @@ class FileManagerControllerWithImageInArticleTest extends FileManagerControllerT
$banner
=
$this
->
fixture
(
'Class_Article'
,
[
'id'
=>
1
,
'titre'
=>
'Banner article'
,
'contenu'
=>
'<img src="https:// '
.
BASE_URL
.
'userfiles/image/home.jpg"></>'
]);
'contenu'
=>
'<img src="https:// '
.
BASE_URL
.
'userfiles/image/home.jpg"></>'
]);
$disk
=
Class_FileManager
::
getFileSystem
()
->
whenCalled
(
'directoryAt'
)
...
...
@@ -1489,10 +1489,10 @@ class FileManagerControllerWithSpecialCharTest extends FileManagerControllerTest
public
function
setUp
()
{
parent
::
setUp
();
$image
=
(
new
Class_FileManager
)
->
setId
(
'userfiles/my\'directory/new_image.jpg'
)
->
setPath
(
'userfiles/my\'directory/new_image.jpg'
)
->
setParentPath
(
'userfiles/my\'directory'
)
->
setName
(
'new_image.jpg'
)
->
setId
(
'userfiles/my\'direct
"
ory/new
\'
_ima
"
ge.jpg'
)
->
setPath
(
'userfiles/my\'direct
"
ory/new
\'
_ima
"
ge.jpg'
)
->
setParentPath
(
'userfiles/my\'direct
"
ory'
)
->
setName
(
'new
\'
_ima
"
ge.jpg'
)
->
setDir
(
false
)
->
setExtension
(
'jpg'
)
->
setDimensions
(
'1920x1080'
);
...
...
@@ -1500,27 +1500,36 @@ class FileManagerControllerWithSpecialCharTest extends FileManagerControllerTest
Class_FileManager
::
getFileSystem
()
->
whenCalled
(
'directoryAt'
)
->
with
(
'userfiles/my\'directory/new_image.jpg'
)
->
with
(
'userfiles/my\'direct
"
ory/new
\'
_ima
"
ge.jpg'
)
->
answers
(
null
)
->
whenCalled
(
'fileAt'
)
->
with
(
'userfiles/my\'directory/new_image.jpg'
)
->
with
(
'userfiles/my\'direct
"
ory/new
\'
_ima
"
ge.jpg'
)
->
answers
(
$image
)
->
whenCalled
(
'directoryAt'
)
->
with
(
'userfiles/my\'directory'
)
->
with
(
'userfiles/my\'direct
"
ory'
)
->
answers
(
null
)
->
whenCalled
(
'fileAt'
)
->
with
(
'userfiles/my\'directory'
)
->
answers
(
null
)
;
->
with
(
'userfiles/my\'direct
"
ory'
)
->
answers
(
null
);
$this
->
dispatch
(
'/admin/file-manager/index?browser=userfiles%2Fmy%27directory%2Fnew_image.jpg&selectable_extensions=jpg;png'
,
true
);
$this
->
dispatch
(
'/admin/file-manager/index?browser=userfiles%2Fmy%27direct
"
ory%2Fnew
%27
_ima
"
ge.jpg&selectable_extensions=jpg;png'
,
true
);
}
/** @test */
/** @test */
public
function
selectButtonShouldBePresent
()
{
$this
->
assertXPathContentContains
(
'//div//a[contains(@onclick, "$(this).selectItemForCKEditor(
\'/stl
/userfiles/my%27directory/
coffee-mug.png\');
")]'
,
'Sélectionner'
,
$this
->
_response
->
getBody
()
);
$this
->
assertXPathContentContains
(
'//div//a[contains(@onclick, "$(this).selectItemForCKEditor(
")][contains(@onclick, "
/userfiles/my%27direct
%22
ory/
new%27_ima%22ge.jpg
")]'
,
'Sélectionner'
);
}
/** @test */
public
function
accessInNewTabShouldBePresent
()
{
$this
->
assertXPathContentContains
(
'//div//a[contains(@href, "/userfiles%2Fmy%27direct%22ory%2Fnew%27_ima%22ge.jpg?version=")][@target="_blank"]'
,
'Accéder à '
);
}
/** @test */
public
function
downloadLinkShouldBePresent
()
{
$this
->
assertXPathContentContains
(
'//div//a[contains(@href, "/userfiles%2Fmy%27direct%22ory%2Fnew%27_ima%22ge.jpg")]'
,
'Télécharger'
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment