Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
761b2d05
Commit
761b2d05
authored
11 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix: delete of files with [ and glob.
parent
7ff2e559
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build/debian/dolibarr.postinst
+11
-11
11 additions, 11 deletions
build/debian/dolibarr.postinst
htdocs/core/lib/files.lib.php
+4
-2
4 additions, 2 deletions
htdocs/core/lib/files.lib.php
test/phpunit/FilesLibTest.php
+11
-1
11 additions, 1 deletion
test/phpunit/FilesLibTest.php
with
26 additions
and
14 deletions
build/debian/dolibarr.postinst
+
11
−
11
View file @
761b2d05
...
...
@@ -94,17 +94,17 @@ case "$1" in
else
# File already exist. We add params not found.
echo
Add new params to overwrite path to use shared libraries/fonts
grep
-q
-c
"dolibarr_lib_ADODB_PATH"
$config
||
[
!
-d
"/usr/share/
php
/adodb"
]
||
echo
"<?php
\$
dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>"
>>
$config
grep
-q
-c
"dolibarr_lib_FPDI_PATH"
$config
||
[
!
-d
"/usr/share/
php
/fpdi"
]
||
echo
"<?php
\$
dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>"
>>
$config
#grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
grep
-q
-c
"dolibarr_lib_NUSOAP_PATH"
$config
||
[
!
-d
"/usr/share/
php
/nusoap"
]
||
echo
"<?php
\$
dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>"
>>
$config
grep
-q
-c
"dolibarr_lib_ODTPHP_PATHTOPCLZIP"
$config
||
[
!
-d
"/usr/share/
php/libphp-
pclzip
"
]
||
echo
"<?php
\$
dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>"
>>
$config
#grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "<?php \$dolibarr_lib_PHPEXCEL_PATH=''; ?>" >> $config
#grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "<?php \$dolibarr_lib_TCPDF_PATH=''; ?>" >> $config
grep
-q
-c
"dolibarr_js_CKEDITOR"
$config
||
[
!
-d
"/usr/share/
javascript
/ckeditor"
]
||
echo
"<?php
\$
dolibarr_js_CKEDITOR='/javascript/ckeditor'; ?>"
>>
$config
grep
-q
-c
"dolibarr_js_JQUERY"
$config
||
[
!
-d
"/usr/share/
javascript
/jquery"
]
||
echo
"<?php
\$
dolibarr_js_JQUERY='/javascript/jquery'; ?>"
>>
$config
grep
-q
-c
"dolibarr_js_JQUERY_UI"
$config
||
[
!
-d
"/usr/share/
javascript
/jquery
-ui
"
]
||
echo
"<?php
\$
dolibarr_js_JQUERY_UI='/javascript/jquery-ui'; ?>"
>>
$config
grep
-q
-c
"dolibarr_js_JQUERY_FLOT"
$config
||
[
!
-d
"/usr/share/
javascript
/flot"
]
||
echo
"<?php
\$
dolibarr_js_JQUERY_FLOT='/javascript/flot'; ?>"
>>
$config
grep
-q
-c
"dolibarr_lib_ADODB_PATH"
$config
||
[
-d
"/usr/share/
dolibarr/htdocs/includes
/adodb
time
"
]
||
echo
"<?php
\$
dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>"
>>
$config
grep
-q
-c
"dolibarr_lib_FPDI_PATH"
$config
||
[
-d
"/usr/share/
dolibarr/htdocs/includes
/fpd
f
i"
]
||
echo
"<?php
\$
dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>"
>>
$config
#grep -q -c "dolibarr_lib_GEOIP_PATH" $config
|| echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
grep
-q
-c
"dolibarr_lib_NUSOAP_PATH"
$config
||
[
-d
"/usr/share/
dolibarr/htdocs/includes
/nusoap"
]
||
echo
"<?php
\$
dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>"
>>
$config
grep
-q
-c
"dolibarr_lib_ODTPHP_PATHTOPCLZIP"
$config
||
[
!
-d
"/usr/share/
dolibarr/htdocs/includes/odtphp/zip/
pclzip ] || echo "
<?php
\$
dolibarr_lib_ODTPHP_PATHTOPCLZIP
=
'/usr/share/php/libphp-pclzip'
;
?>
" >>
$config
#grep -q -c "
dolibarr_lib_PHPEXCEL_PATH
"
$config
|| echo "
<?php
\$
dolibarr_lib_PHPEXCEL_PATH
=
''
;
?>
" >>
$config
#grep -q -c "
dolibarr_lib_TCPDF_PATH
"
$config
|| echo "
<?php
\$
dolibarr_lib_TCPDF_PATH
=
''
;
?>
" >>
$config
grep -q -c "
dolibarr_js_CKEDITOR
"
$config
|| [ -d "
/usr/share/
dolibarr/htdocs/includes
/ckeditor
" ] || echo "
<?php
\$
dolibarr_js_CKEDITOR
=
'/javascript/ckeditor'
;
?>
" >>
$config
grep -q -c "
dolibarr_js_JQUERY
"
$config
|| [ -d "
/usr/share/
dolibarr/htdocs/includes
/jquery
/js
" ] || echo "
<?php
\$
dolibarr_js_JQUERY
=
'/javascript/jquery'
;
?>
" >>
$config
grep -q -c "
dolibarr_js_JQUERY_UI
"
$config
|| [ -d "
/usr/share/
dolibarr/htdocs/includes
/jquery
/js
" ] || echo "
<?php
\$
dolibarr_js_JQUERY_UI
=
'/javascript/jquery-ui'
;
?>
" >>
$config
grep -q -c "
dolibarr_js_JQUERY_FLOT
"
$config
|| [ -d "
/usr/share/
dolibarr/htdocs/includes/jquery/plugins
/flot
" ] || echo "
<?php
\$
dolibarr_js_JQUERY_FLOT
=
'/javascript/flot'
;
?>
" >>
$config
grep -q -c "
dolibarr_font_DOL_DEFAULT_TTF_BOLD
"
$config
|| echo "
<?php
\$
dolibarr_font_DOL_DEFAULT_TTF_BOLD
=
'/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf'
;
?>
" >>
$config
fi
...
...
This diff is collapsed.
Click to expand it.
htdocs/core/lib/files.lib.php
+
4
−
2
View file @
761b2d05
...
...
@@ -729,12 +729,14 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
{
$error
=
0
;
//print "x".$file." ".$disableglob;
//print "x".$file." ".$disableglob;
exit;
$ok
=
true
;
$file_osencoded
=
dol_osencode
(
$file
);
// New filename encoded in OS filesystem encoding charset
if
(
empty
(
$disableglob
)
&&
!
empty
(
$file_osencoded
))
{
foreach
(
glob
(
$file_osencoded
)
as
$filename
)
$globencoded
=
str_replace
(
'['
,
'\['
,
$file_osencoded
);
$globencoded
=
str_replace
(
']'
,
'\]'
,
$globencoded
);
foreach
(
glob
(
$globencoded
)
as
$filename
)
{
if
(
$nophperrors
)
$ok
=@
unlink
(
$filename
);
// The unlink encapsulated by dolibarr
else
$ok
=
unlink
(
$filename
);
// The unlink encapsulated by dolibarr
...
...
This diff is collapsed.
Click to expand it.
test/phpunit/FilesLibTest.php
+
11
−
1
View file @
761b2d05
...
...
@@ -326,7 +326,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
// Again to test with overwriting=1
$result
=
dol_copy
(
$file
,
$conf
->
admin
->
dir_temp
.
'/file.csv'
,
0
,
1
);
print
__METHOD__
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertGreaterThanOrEqual
(
1
,
$result
,
'copy destination already eists, overwrite'
);
// Should be 1
$this
->
assertGreaterThanOrEqual
(
1
,
$result
,
'copy destination already e
x
ists, overwrite'
);
// Should be 1
// Again to test with overwriting=1
$result
=
dol_move
(
$conf
->
admin
->
dir_temp
.
'/file.csv'
,
$conf
->
admin
->
dir_temp
.
'/file2.csv'
,
0
,
1
);
...
...
@@ -341,6 +341,16 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
$result
=
dol_delete_file
(
$conf
->
admin
->
dir_temp
.
'/file2.csv'
);
print
__METHOD__
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertTrue
(
$result
,
'delete file that does not exists'
);
// Test copy with special char / delete with blob
$result
=
dol_copy
(
$file
,
$conf
->
admin
->
dir_temp
.
'/file with [x] and é.csv'
,
0
,
1
);
print
__METHOD__
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertGreaterThanOrEqual
(
1
,
$result
,
'copy destination already exists, overwrite'
);
// Should be 1
// Try to delete using a glob criteria
$result
=
dol_delete_file
(
$conf
->
admin
->
dir_temp
.
'/file with [x]*é.csv'
);
print
__METHOD__
.
" result="
.
$result
.
"
\n
"
;
$this
->
assertTrue
(
$result
,
'delete file that does not exists'
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment