Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
BRIC
dokuwiki
Commits
f59b22f0
Commit
f59b22f0
authored
20 years ago
by
andi
Browse files
Options
Downloads
Patches
Plain Diff
safe mode for utf8_encodeFN
darcs-hash:20050123182753-9977f-9226687e01f083dbeea7a205db30a6d74ed2eb5f.gz
parent
d5a2a500
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/utf8.php
+15
-4
15 additions, 4 deletions
inc/utf8.php
with
15 additions
and
4 deletions
inc/utf8.php
+
15
−
4
View file @
f59b22f0
...
...
@@ -11,10 +11,19 @@
*
* Slashes are not encoded
*
* When the second parameter is true the string will
* be encoded only if non ASCII characters are detected -
* This makes it safe to run it multiple times on the
* same string (default is true)
*
* @author Andreas Gohr <andi@splitbrain.org>
* @see urlencode
*/
function
utf8_encodeFN
(
$file
){
$file
=
rawurlencode
(
$file
);
function
utf8_encodeFN
(
$file
,
$safe
=
true
){
if
(
$safe
&&
preg_match
(
'#^[a-zA-Z0-9/_\-.%]+$#'
,
$file
)){
return
$file
;
}
$file
=
urlencode
(
$file
);
$file
=
str_replace
(
'%2F'
,
'/'
,
$file
);
return
$file
;
}
...
...
@@ -22,10 +31,13 @@ function utf8_encodeFN($file){
/**
* URL-Decode a filename
*
* This is just a wrapper around urldecode
*
* @author Andreas Gohr <andi@splitbrain.org>
* @see urldecode
*/
function
utf8_decodeFN
(
$file
){
$file
=
raw
urldecode
(
$file
);
$file
=
urldecode
(
$file
);
return
$file
;
}
...
...
@@ -52,7 +64,6 @@ function utf8_check($Str) {
return
true
;
}
/**
* This is a unicode aware replacement for strlen()
*
...
...
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