Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jvoisin
mat2
Commits
f67cd9d7
Commit
f67cd9d7
authored
5 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Improve the robustness of the CSS parser
parent
615997be
No related branches found
No related tags found
1 merge request
!72
Improve the robustness of the CSS parser
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
libmat2/web.py
+10
-2
10 additions, 2 deletions
libmat2/web.py
with
10 additions
and
2 deletions
libmat2/web.py
+
10
−
2
View file @
f67cd9d7
...
...
@@ -17,7 +17,11 @@ class CSSParser(abstract.AbstractParser):
def
remove_all
(
self
)
->
bool
:
with
open
(
self
.
filename
,
encoding
=
'
utf-8
'
)
as
f
:
cleaned
=
re
.
sub
(
r
'
/\*.*?\*/
'
,
''
,
f
.
read
(),
0
,
self
.
flags
)
try
:
content
=
f
.
read
()
except
UnicodeDecodeError
:
# pragma: no cover
raise
ValueError
cleaned
=
re
.
sub
(
r
'
/\*.*?\*/
'
,
''
,
content
,
0
,
self
.
flags
)
with
open
(
self
.
output_filename
,
'
w
'
,
encoding
=
'
utf-8
'
)
as
f
:
f
.
write
(
cleaned
)
return
True
...
...
@@ -25,7 +29,11 @@ class CSSParser(abstract.AbstractParser):
def
get_meta
(
self
)
->
Dict
[
str
,
Any
]:
metadata
=
{}
with
open
(
self
.
filename
,
encoding
=
'
utf-8
'
)
as
f
:
cssdoc
=
re
.
findall
(
r
'
/\*(.*?)\*/
'
,
f
.
read
(),
self
.
flags
)
try
:
content
=
f
.
read
()
except
UnicodeDecodeError
:
# pragma: no cover
raise
ValueError
cssdoc
=
re
.
findall
(
r
'
/\*(.*?)\*/
'
,
content
,
self
.
flags
)
for
match
in
cssdoc
:
for
line
in
match
.
splitlines
():
try
:
...
...
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