Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
b5b6a80f
Commit
b5b6a80f
authored
Apr 28, 2016
by
Aaron Wells
Committed by
Gerrit Code Review
Apr 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge "Bug 1536895: Upgrade CSSTidy to 1.5.5" into 16.04_STABLE
parents
38ccef5d
c1a9c856
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
33 deletions
+42
-33
htdocs/lib/csstidy/README.Mahara
htdocs/lib/csstidy/README.Mahara
+1
-1
htdocs/lib/csstidy/class.csstidy.php
htdocs/lib/csstidy/class.csstidy.php
+31
-25
htdocs/lib/csstidy/class.csstidy_optimise.php
htdocs/lib/csstidy/class.csstidy_optimise.php
+3
-2
htdocs/lib/csstidy/class.csstidy_print.php
htdocs/lib/csstidy/class.csstidy_print.php
+7
-5
No files found.
htdocs/lib/csstidy/README.Mahara
100755 → 100644
View file @
b5b6a80f
...
...
@@ -2,7 +2,7 @@ CSSTidy in Mahara
=================
Website: https://github.com/Cerdic/CSSTidy
Version: 1.5.
2
Version: 1.5.
5
This library is used by clean_css, to strip out malicious CSS
...
...
htdocs/lib/csstidy/class.csstidy.php
View file @
b5b6a80f
...
...
@@ -33,23 +33,28 @@
*/
/**
* Defines ctype functions if required
* @todo make them methods of csstidy class
* @version 1.0
* Defines ctype functions if required.
*
* @TODO: Make these methods of CSSTidy.
* @since 1.0.0
*/
if
(
!
function_exists
(
'ctype_space'
))
{
/* ctype_space
Check for whitespace character(s) */
function
ctype_space
(
$text
)
{
return
!
preg_match
(
"/
[^\s
\r\n\t\f
]/"
,
$text
);
if
(
!
function_exists
(
'ctype_space'
)){
/* ctype_space Check for whitespace character(s) */
function
ctype_space
(
$text
){
return
(
1
===
preg_match
(
"/
^[
\r\n\t\f
]
+$
/"
,
$text
)
)
;
}
}
if
(
!
function_exists
(
'ctype_alpha'
))
{
/* ctype_alpha Check for alphabetic character(s) */
function
ctype_alpha
(
$text
)
{
return
preg_match
(
"/[a-zA-Z]/"
,
$text
);
if
(
!
function_exists
(
'ctype_alpha'
)){
/* ctype_alpha Check for alphabetic character(s) */
function
ctype_alpha
(
$text
){
return
(
1
===
preg_match
(
'/^[a-zA-Z]+$/'
,
$text
));
}
}
if
(
!
function_exists
(
'ctype_xdigit'
)){
/* ctype_xdigit Check for HEX character(s) */
function
ctype_xdigit
(
$text
){
return
(
1
===
preg_match
(
'/^[a-fA-F0-9]+$/'
,
$text
));
}
}
/**
...
...
@@ -89,7 +94,7 @@ require('class.csstidy_optimise.php');
* An online version should be available here: http://cdburnerxp.se/cssparse/css_optimiser.php
* @package csstidy
* @author Florian Schmitz (floele at gmail dot com) 2005-2006
* @version 1.5.
2
* @version 1.5.
5
*/
class
csstidy
{
...
...
@@ -111,11 +116,11 @@ class csstidy {
* @access public
*/
public
$cur_comments
=
array
();
/**
* Saves the parsed CSS (raw)
* @var array
* @access p
ublic
*/
/**
* Saves the parsed CSS (raw)
* @var array
* @access p
rivate
*/
public
$tokens
=
array
();
/**
* Printer class
...
...
@@ -154,7 +159,7 @@ class csstidy {
* @var string
* @access private
*/
public
$version
=
'1.5.
2
'
;
public
$version
=
'1.5.
5
'
;
/**
* Stores the settings
* @var array
...
...
@@ -309,6 +314,7 @@ class csstidy {
*/
$this
->
settings
[
'optimise_shorthands'
]
=
1
;
$this
->
settings
[
'remove_last_;'
]
=
true
;
$this
->
settings
[
'space_before_important'
]
=
false
;
/* rewrite all properties with low case, better for later gzip OK, safe*/
$this
->
settings
[
'case_properties'
]
=
1
;
/* sort properties in alpabetic order, better for later gzip
...
...
@@ -328,7 +334,7 @@ class csstidy {
$this
->
settings
[
'discard_invalid_properties'
]
=
false
;
$this
->
settings
[
'css_level'
]
=
'CSS3.0'
;
$this
->
settings
[
'preserve_css'
]
=
false
;
$this
->
settings
[
'preserve_css_comment'
]
=
false
;
$this
->
settings
[
'preserve_css_comment'
]
=
false
;
$this
->
settings
[
'timestamp'
]
=
false
;
$this
->
settings
[
'template'
]
=
''
;
// say that propertie exist
$this
->
set_cfg
(
'template'
,
'default'
);
// call load_template
...
...
@@ -629,7 +635,7 @@ class csstidy {
$this
->
at
.
=
$this
->
_unicode
(
$string
,
$i
);
}
// fix for complicated media, i.e @media screen and (-webkit-min-device-pixel-ratio:1.5)
elseif
(
in_array
(
$string
{
$i
},
array
(
'('
,
')'
,
':'
,
'.'
)))
{
elseif
(
in_array
(
$string
{
$i
},
array
(
'('
,
')'
,
':'
,
'.'
,
'/'
)))
{
$this
->
at
.
=
$string
{
$i
};
}
}
else
{
...
...
@@ -707,8 +713,8 @@ class csstidy {
$this
->
sel_separate
[]
=
strlen
(
$this
->
selector
);
}
elseif
(
$string
{
$i
}
===
'\\'
)
{
$this
->
selector
.
=
$this
->
_unicode
(
$string
,
$i
);
}
elseif
(
$string
{
$i
}
===
'*'
&&
@
in_array
(
$string
{
$i
+
1
},
array
(
'.'
,
'#'
,
'['
,
':'
)))
{
// remove unnecessary universal selector, FS#147
}
elseif
(
$string
{
$i
}
===
'*'
&&
@
in_array
(
$string
{
$i
+
1
},
array
(
'.'
,
'#'
,
'['
,
':'
))
&&
(
$i
==
0
OR
$string
{
$i
-
1
}
!==
'/'
)
)
{
// remove unnecessary universal selector, FS#147
, but not comment in selector
}
else
{
$this
->
selector
.
=
$string
{
$i
};
}
...
...
@@ -848,7 +854,7 @@ class csstidy {
}
}
$previous_property
=
$this
->
property
;
$previous_property
=
$this
->
property
;
$this
->
property
=
''
;
$this
->
sub_value_arr
=
array
();
$this
->
value
=
''
;
...
...
htdocs/lib/csstidy/class.csstidy_optimise.php
View file @
b5b6a80f
...
...
@@ -269,7 +269,8 @@ class csstidy_optimise {
*/
public
function
compress_important
(
&
$string
)
{
if
(
$this
->
parser
->
is_important
(
$string
))
{
$string
=
$this
->
parser
->
gvw_important
(
$string
)
.
'!important'
;
$important
=
$this
->
parser
->
get_cfg
(
'space_before_important'
)
?
' !important'
:
'!important'
;
$string
=
$this
->
parser
->
gvw_important
(
$string
)
.
$important
;
}
return
$string
;
}
...
...
@@ -899,7 +900,7 @@ class csstidy_optimise {
$new_font_value
=
''
;
$important
=
''
;
// Skip if not font-family and font-size set
if
(
isset
(
$input_css
[
'font-family'
])
&&
isset
(
$input_css
[
'font-size'
]))
{
if
(
isset
(
$input_css
[
'font-family'
])
&&
isset
(
$input_css
[
'font-size'
])
&&
$input_css
[
'font-family'
]
!=
'inherit'
)
{
// fix several words in font-family - add quotes
if
(
isset
(
$input_css
[
'font-family'
]))
{
$families
=
explode
(
','
,
$input_css
[
'font-family'
]);
...
...
htdocs/lib/csstidy/class.csstidy_print.php
View file @
b5b6a80f
...
...
@@ -262,9 +262,11 @@ class csstidy_print {
case
AT_END
:
$out
=
&
$output
;
$out
.
=
$template
[
10
]
.
str_replace
(
"
\n
"
,
"
\n
"
.
$template
[
10
],
$in_at_out
);
$in_at_out
=
str_replace
(
"
\n\n
"
,
"
\r\n
"
,
$in_at_out
);
// don't fill empty lines
$in_at_out
=
str_replace
(
"
\n
"
,
"
\n
"
.
$template
[
10
],
$in_at_out
);
$in_at_out
=
str_replace
(
"
\r\n
"
,
"
\n\n
"
,
$in_at_out
);
$out
.
=
$template
[
10
]
.
$in_at_out
.
$template
[
9
];
$in_at_out
=
''
;
$out
.
=
$template
[
9
];
break
;
case
COMMENT
:
...
...
@@ -343,9 +345,9 @@ class csstidy_print {
foreach
(
$val
as
$selector
=>
$vali
)
{
if
(
$sort_properties
)
ksort
(
$vali
);
if
(
!
empty
(
$this
->
parser
->
comments
[
$medium
.
$selector
]))
{
$this
->
parser
->
_add_token
(
COMMENT
,
implode
(
'. '
,
$this
->
parser
->
comments
[
$medium
.
$selector
]),
true
);
}
if
(
!
empty
(
$this
->
parser
->
comments
[
$medium
.
$selector
]))
{
$this
->
parser
->
_add_token
(
COMMENT
,
implode
(
'. '
,
$this
->
parser
->
comments
[
$medium
.
$selector
]),
true
);
}
$this
->
parser
->
_add_token
(
SEL_START
,
$selector
,
true
);
$invalid
=
array
(
...
...
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