Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
15cb4892
Kaydet (Commit)
15cb4892
authored
Kas 18, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#13358: HTMLParser now calls handle_data only once for each CDATA.
üst
8008f2ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
parser.py
Lib/html/parser.py
+4
-3
test_htmlparser.py
Lib/test/test_htmlparser.py
+21
-1
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/html/parser.py
Dosyayı görüntüle @
15cb4892
...
...
@@ -14,7 +14,6 @@ import re
# Regular expressions used for parsing
interesting_normal
=
re
.
compile
(
'[&<]'
)
interesting_cdata
=
re
.
compile
(
r'<(/|\Z)'
)
incomplete
=
re
.
compile
(
'&[a-zA-Z#]'
)
entityref
=
re
.
compile
(
'&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]'
)
...
...
@@ -149,8 +148,8 @@ class HTMLParser(_markupbase.ParserBase):
return
self
.
__starttag_text
def
set_cdata_mode
(
self
,
elem
):
self
.
interesting
=
interesting_cdata
self
.
cdata_elem
=
elem
.
lower
()
self
.
interesting
=
re
.
compile
(
r'</\s*
%
s\s*>'
%
self
.
cdata_elem
,
re
.
I
)
def
clear_cdata_mode
(
self
):
self
.
interesting
=
interesting_normal
...
...
@@ -168,6 +167,8 @@ class HTMLParser(_markupbase.ParserBase):
if
match
:
j
=
match
.
start
()
else
:
if
self
.
cdata_elem
:
break
j
=
n
if
i
<
j
:
self
.
handle_data
(
rawdata
[
i
:
j
])
i
=
self
.
updatepos
(
i
,
j
)
...
...
@@ -250,7 +251,7 @@ class HTMLParser(_markupbase.ParserBase):
else
:
assert
0
,
"interesting.search() lied"
# end while
if
end
and
i
<
n
:
if
end
and
i
<
n
and
not
self
.
cdata_elem
:
self
.
handle_data
(
rawdata
[
i
:
n
])
i
=
self
.
updatepos
(
i
,
n
)
self
.
rawdata
=
rawdata
[
i
:]
...
...
Lib/test/test_htmlparser.py
Dosyayı görüntüle @
15cb4892
...
...
@@ -301,7 +301,27 @@ DOCTYPE html [
(
"data"
,
content
),
(
"endtag"
,
element_lower
)])
def
test_cdata_with_closing_tags
(
self
):
# see issue #13358
# make sure that HTMLParser calls handle_data only once for each CDATA.
# The normal event collector normalizes the events in get_events,
# so we override it to return the original list of events.
class
Collector
(
EventCollector
):
def
get_events
(
self
):
return
self
.
events
content
=
"""<!-- not a comment --> ¬-an-entity-ref;
<a href="" /> </p><p> <span></span></style>
'</script' + '>'"""
for
element
in
[
' script'
,
'script '
,
' script '
,
'
\n
script'
,
'script
\n
'
,
'
\n
script
\n
'
]:
element_lower
=
element
.
lower
()
.
strip
()
s
=
'<script>{content}</{element}>'
.
format
(
element
=
element
,
content
=
content
)
self
.
_run_check
(
s
,
[(
"starttag"
,
element_lower
,
[]),
(
"data"
,
content
),
(
"endtag"
,
element_lower
)],
collector
=
Collector
())
class
HTMLParserTolerantTestCase
(
HTMLParserStrictTestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
15cb4892
...
...
@@ -76,6 +76,8 @@ Core and Builtins
Library
-------
- Issue #13358: HTMLParser now calls handle_data only once for each CDATA.
- Issue #4147: minidom's toprettyxml no longer adds whitespace around a text
node when it is the only child of an element. Initial patch by Dan
Kenigsberg.
...
...
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