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
6e0b4b67
Commit
6e0b4b67
authored
14 years ago
by
Michael Hamann
Browse files
Options
Downloads
Patches
Plain Diff
Fixed css_loadfile and removed unneeded complexity, added testcases
parent
f7d780b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_test/cases/lib/exe/css_css_loadfile.test.php
+57
-0
57 additions, 0 deletions
_test/cases/lib/exe/css_css_loadfile.test.php
lib/exe/css.php
+2
-2
2 additions, 2 deletions
lib/exe/css.php
with
59 additions
and
2 deletions
_test/cases/lib/exe/css_css_loadfile.test.php
0 → 100644
+
57
−
0
View file @
6e0b4b67
<?php
require_once
DOKU_INC
.
'lib/exe/css.php'
;
class
css_css_loadfile_test
extends
UnitTestCase
{
public
function
setUp
()
{
$this
->
file
=
tempnam
(
'/tmp'
,
'css'
);
parent
::
setUp
();
}
private
function
csstest
(
$input
,
$output
=
null
,
$location
=
'http://www.example.com/'
)
{
io_saveFile
(
$this
->
file
,
$input
);
$this
->
assertEqual
(
css_loadfile
(
$this
->
file
,
$location
),
(
is_null
(
$output
)
?
$input
:
$output
));
}
public
function
test_url_relative
()
{
$this
->
csstest
(
'#test { background: url("test/test.png"); }'
,
'#test { background: url("http://www.example.com/test/test.png"); }'
);
$this
->
csstest
(
'#test { background: url(\'test/test.png\'); }'
,
'#test { background: url(\'http://www.example.com/test/test.png\'); }'
);
}
public
function
test_url_absolute
()
{
$this
->
csstest
(
'#test { background: url("/test/test.png"); }'
);
$this
->
csstest
(
'#test { background: url(\'/test/test.png\'); }'
);
}
public
function
test_url_with_protocol
()
{
$this
->
csstest
(
'#test { background: url("http://www.test.com/test/test.png"); }'
);
$this
->
csstest
(
'#test { background: url("https://www.test.com/test/test.png"); }'
);
$this
->
csstest
(
'#test { background: url(\'http://www.test.com/test/test.png\'); }'
);
$this
->
csstest
(
'#test { background: url(\'https://www.test.com/test/test.png\'); }'
);
}
public
function
test_import_relative
()
{
$this
->
csstest
(
'@import "test/test.png";'
,
'@import "http://www.example.com/test/test.png";'
);
$this
->
csstest
(
'@import \'test/test.png\';'
,
'@import \'http://www.example.com/test/test.png\';'
);
}
public
function
test_import_absolute
()
{
$this
->
csstest
(
'@import "/test/test.png";'
);
$this
->
csstest
(
'@import \'/test/test.png\';'
);
}
public
function
test_import_with_protocol
()
{
$this
->
csstest
(
'@import "http://www.test.com/test/test.png";'
);
$this
->
csstest
(
'@import "https://www.test.com/test/test.png";'
);
$this
->
csstest
(
'@import \'http://www.test.com/test/test.png\';'
);
$this
->
csstest
(
'@import \'https://www.test.com/test/test.png\';'
);
}
public
function
tearDown
()
{
unlink
(
$this
->
file
);
unset
(
$this
->
file
);
parent
::
tearDown
();
}
}
//Setup VIM: ex: et ts=4 sw=4 :
This diff is collapsed.
Click to expand it.
lib/exe/css.php
+
2
−
2
View file @
6e0b4b67
...
...
@@ -267,8 +267,8 @@ function css_loadfile($file,$location=''){
$css
=
io_readFile
(
$file
);
if
(
!
$location
)
return
$css
;
$css
=
preg_replace
(
'#(url\([ \'"]*)(
(
?!/|http://|https://| |\'|")
)
#'
,
'\\1'
.
$location
.
'\\3'
,
$css
);
$css
=
preg_replace
(
'#(@import\s+[\'"])(
(
?!/|http://|https://)
)
#'
,
'\\1'
.
$location
.
'\\2"'
,
$css
);
$css
=
preg_replace
(
'#(url\([ \'"]*)(?!/|http://|https://| |\'|")#'
,
'\\1'
.
$location
,
$css
);
$css
=
preg_replace
(
'#(@import\s+[\'"])(?!/|http://|https://)#'
,
'\\1'
.
$location
,
$css
);
return
$css
;
}
...
...
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