css_parser 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/css_parser/regexps.rb +21 -14
- data/lib/css_parser/rule_set.rb +10 -4
- data/lib/css_parser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed961d9c30e5f86976f527c41b777f29bdd558b5e149985e536ba74876fbb6c8
|
|
4
|
+
data.tar.gz: d12338993a30625469c3cd7ff81932744c877f945a4b361a524744593589a820
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1c189987171a935f347f7fe7f1f528ae2b2ce2d6880eaf6f124ea05c45b4af02685bf765b128188fdc33add0bde3b76b401a99d8268f1534feba6e962a35632
|
|
7
|
+
data.tar.gz: 5cc19fa3c0047c20331240acd7c3064afdae0d43227de44a7a347eb7239119b09b287225cfaf8840535aa59ce9511f7b467c059b18298424c55231276cb2db3f
|
data/lib/css_parser/regexps.rb
CHANGED
|
@@ -61,20 +61,27 @@ module CssParser
|
|
|
61
61
|
RE_BORDER_UNITS = Regexp.union(BOX_MODEL_UNITS_RX, /(thin|medium|thick)/i)
|
|
62
62
|
|
|
63
63
|
# Functions like calc, var, clamp, etc.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
# Possessive quantifiers + recursion-first alternation avoid exponential
|
|
65
|
+
# backtracking on unclosed functions, the timeout is a backstop.
|
|
66
|
+
RE_FUNCTIONS = Regexp.new(
|
|
67
|
+
/
|
|
68
|
+
(
|
|
69
|
+
[a-z0-9-]+ # function name
|
|
70
|
+
)
|
|
71
|
+
(?>
|
|
72
|
+
\( # opening parenthesis
|
|
73
|
+
(?:
|
|
74
|
+
\g<0> # nested function
|
|
75
|
+
|
|
|
76
|
+
[^()a-z0-9]++
|
|
77
|
+
|
|
|
78
|
+
[a-z0-9-]++ (?!\()
|
|
79
|
+
)*
|
|
80
|
+
\) # closing parenthesis
|
|
81
|
+
)
|
|
82
|
+
/imx,
|
|
83
|
+
timeout: 0.01
|
|
84
|
+
).freeze
|
|
78
85
|
|
|
79
86
|
# Patterns for specificity calculations
|
|
80
87
|
NON_ID_ATTRIBUTES_AND_PSEUDO_CLASSES_RX_NC = /
|
data/lib/css_parser/rule_set.rb
CHANGED
|
@@ -696,10 +696,16 @@ module CssParser
|
|
|
696
696
|
end
|
|
697
697
|
|
|
698
698
|
def split_value_preserving_function_whitespace(value)
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
699
|
+
# hostile values can still hit the regexp timeout, then split without protecting functions
|
|
700
|
+
split_value =
|
|
701
|
+
begin
|
|
702
|
+
value.gsub(RE_FUNCTIONS) do |c|
|
|
703
|
+
c.gsub!(/\s+/, WHITESPACE_REPLACEMENT)
|
|
704
|
+
c
|
|
705
|
+
end
|
|
706
|
+
rescue Regexp::TimeoutError
|
|
707
|
+
value
|
|
708
|
+
end
|
|
703
709
|
|
|
704
710
|
matches = split_value.strip.split(/\s+/)
|
|
705
711
|
|
data/lib/css_parser/version.rb
CHANGED