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
736007f7
Commit
736007f7
authored
18 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
let's freeze even less
parent
5d2257f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/htmltextview.py
+20
-6
20 additions, 6 deletions
src/htmltextview.py
with
20 additions
and
6 deletions
src/htmltextview.py
+
20
−
6
View file @
736007f7
...
...
@@ -36,6 +36,7 @@ import re
import
warnings
from
cStringIO
import
StringIO
import
socket
import
time
import
urllib2
import
operator
...
...
@@ -689,18 +690,31 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
gajim
.
log
.
debug
(
str
(
'
Error loading image %s
'
%
attrs
[
'
src
'
]
+
ex
))
pixbuf
=
None
alt
=
attrs
.
get
(
'
alt
'
,
'
Broken image
'
)
try
:
loader
.
close
()
except
:
pass
else
:
# Wait 10ms between each byte
try
:
f
.
fp
.
_sock
.
fp
.
_sock
.
settimeout
(
0.01
)
except
:
pass
# Max image size = 2 MB (to try to prevent DoS)
mem
=
f
.
read
(
2
*
1024
*
1024
)
# Max image size = 2 MB (to try to prevent DoS) in Max 3s
mem
=
''
deadline
=
time
.
time
()
+
3
while
True
:
if
time
.
time
()
>
deadline
:
gajim
.
log
.
debug
(
str
(
'
Timeout loading image %s
'
%
\
attrs
[
'
src
'
]
+
ex
))
pixbuf
=
None
alt
=
attrs
.
get
(
'
alt
'
,
'
Timeout loading image
'
)
break
temp
=
f
.
read
(
100
)
if
temp
:
mem
+=
temp
else
:
break
if
len
(
mem
)
>
2
*
1024
*
1024
:
alt
=
attrs
.
get
(
'
alt
'
,
'
Image is too big
'
)
break
# Caveat: GdkPixbuf is known not to be safe to load
# images from network... this program is now potentially
# hackable ;)
...
...
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