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
6f2bb989
Kaydet (Commit)
6f2bb989
authored
Eyl 06, 2015
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#23144: Make sure that HTMLParser.feed() returns all the data, even when convert_charrefs is True.
üst
527ef079
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
parser.py
Lib/html/parser.py
+9
-1
test_htmlparser.py
Lib/test/test_htmlparser.py
+12
-3
NEWS
Misc/NEWS
+4
-1
No files found.
Lib/html/parser.py
Dosyayı görüntüle @
6f2bb989
...
...
@@ -198,7 +198,15 @@ class HTMLParser(_markupbase.ParserBase):
if
self
.
convert_charrefs
and
not
self
.
cdata_elem
:
j
=
rawdata
.
find
(
'<'
,
i
)
if
j
<
0
:
if
not
end
:
# if we can't find the next <, either we are at the end
# or there's more text incoming. If the latter is True,
# we can't pass the text to handle_data in case we have
# a charref cut in half at end. Try to determine if
# this is the case before proceding by looking for an
# & near the end and see if it's followed by a space or ;.
amppos
=
rawdata
.
rfind
(
'&'
,
max
(
i
,
n
-
34
))
if
(
amppos
>=
0
and
not
re
.
compile
(
r'[\s;]'
)
.
search
(
rawdata
,
amppos
)):
break
# wait till we get all the text
j
=
n
else
:
...
...
Lib/test/test_htmlparser.py
Dosyayı görüntüle @
6f2bb989
...
...
@@ -72,9 +72,6 @@ class EventCollectorExtra(EventCollector):
class
EventCollectorCharrefs
(
EventCollector
):
def
get_events
(
self
):
return
self
.
events
def
handle_charref
(
self
,
data
):
self
.
fail
(
'This should never be called with convert_charrefs=True'
)
...
...
@@ -685,6 +682,18 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
]
self
.
_run_check
(
html
,
expected
)
def
test_convert_charrefs_dropped_text
(
self
):
# #23144: make sure that all the events are triggered when
# convert_charrefs is True, even if we don't call .close()
parser
=
EventCollector
(
convert_charrefs
=
True
)
# before the fix, bar & baz was missing
parser
.
feed
(
"foo <a>link</a> bar & baz"
)
self
.
assertEqual
(
parser
.
get_events
(),
[(
'data'
,
'foo '
),
(
'starttag'
,
'a'
,
[]),
(
'data'
,
'link'
),
(
'endtag'
,
'a'
),
(
'data'
,
' bar & baz'
)]
)
class
AttributesStrictTestCase
(
TestCaseBase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
6f2bb989
+++++++++++
+++++++++++
Python
News
+++++++++++
...
...
@@ -81,6 +81,9 @@ Core and Builtins
Library
-------
-
Issue
#
23144
:
Make
sure
that
HTMLParser
.
feed
()
returns
all
the
data
,
even
when
convert_charrefs
is
True
.
-
Issue
#
16180
:
Exit
pdb
if
file
has
syntax
error
,
instead
of
trapping
user
in
an
infinite
loop
.
Patch
by
Xavier
de
Gaye
.
...
...
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