Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
70e145a8
Commit
70e145a8
authored
15 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
fix traceback preventing showing ALT text of an image. Fixes #5247
parent
4db1d273
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/htmltextview.py
+33
-34
33 additions, 34 deletions
src/htmltextview.py
with
33 additions
and
34 deletions
src/htmltextview.py
+
33
−
34
View file @
70e145a8
...
...
@@ -483,6 +483,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
def
_process_img
(
self
,
attrs
):
'''
Process a img tag.
'''
mem
=
''
try
:
# Wait maximum 1s for connection
socket
.
setdefaulttimeout
(
1
)
...
...
@@ -498,40 +499,38 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
f
.
fp
.
_sock
.
fp
.
_sock
.
settimeout
(
0.5
)
except
Exception
:
pass
# Max image size = 2 MB (to try to prevent DoS)
mem
=
''
deadline
=
time
.
time
()
+
3
while
True
:
if
time
.
time
()
>
deadline
:
gajim
.
log
.
debug
(
str
(
'
Timeout loading image %s
'
%
\
attrs
[
'
src
'
]
+
ex
))
mem
=
''
alt
=
attrs
.
get
(
'
alt
'
,
''
)
if
alt
:
alt
+=
'
\n
'
alt
+=
_
(
'
Timeout loading image
'
)
break
try
:
temp
=
f
.
read
(
100
)
except
socket
.
timeout
,
ex
:
gajim
.
log
.
debug
(
'
Timeout loading image %s
'
%
attrs
[
'
src
'
]
+
\
str
(
ex
))
mem
=
''
alt
=
attrs
.
get
(
'
alt
'
,
''
)
if
alt
:
alt
+=
'
\n
'
alt
+=
_
(
'
Timeout loading image
'
)
break
if
temp
:
mem
+=
temp
else
:
break
if
len
(
mem
)
>
2
*
1024
*
1024
:
alt
=
attrs
.
get
(
'
alt
'
,
''
)
if
alt
:
alt
+=
'
\n
'
alt
+=
_
(
'
Image is too big
'
)
break
# Max image size = 2 MB (to try to prevent DoS)
deadline
=
time
.
time
()
+
3
while
True
:
if
time
.
time
()
>
deadline
:
gajim
.
log
.
debug
(
str
(
'
Timeout loading image %s
'
%
\
attrs
[
'
src
'
]
+
ex
))
mem
=
''
alt
=
attrs
.
get
(
'
alt
'
,
''
)
if
alt
:
alt
+=
'
\n
'
alt
+=
_
(
'
Timeout loading image
'
)
break
try
:
temp
=
f
.
read
(
100
)
except
socket
.
timeout
,
ex
:
gajim
.
log
.
debug
(
'
Timeout loading image %s
'
%
attrs
[
'
src
'
]
+
\
str
(
ex
))
alt
=
attrs
.
get
(
'
alt
'
,
''
)
if
alt
:
alt
+=
'
\n
'
alt
+=
_
(
'
Timeout loading image
'
)
break
if
temp
:
mem
+=
temp
else
:
break
if
len
(
mem
)
>
2
*
1024
*
1024
:
alt
=
attrs
.
get
(
'
alt
'
,
''
)
if
alt
:
alt
+=
'
\n
'
alt
+=
_
(
'
Image is too big
'
)
break
pixbuf
=
None
if
mem
:
# Caveat: GdkPixbuf is known not to be safe to load
...
...
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