aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kelkar <sachinkel19@gmail.com>2017-02-12 01:19:36 +0530
committerSachin Kelkar <sachinkel19@gmail.com>2017-02-12 01:19:36 +0530
commit245e24dcf3327e46b7ce2ea4a4b667c0d90bd1c0 (patch)
tree492d91e92c7900bceff15adf21f60224e3a41cdd
parentccca04b45083ecbde8a05ed709e4062024ab9f8d (diff)
downloadmitmproxy-245e24dcf3327e46b7ce2ea4a4b667c0d90bd1c0.tar.gz
mitmproxy-245e24dcf3327e46b7ce2ea4a4b667c0d90bd1c0.tar.bz2
mitmproxy-245e24dcf3327e46b7ce2ea4a4b667c0d90bd1c0.zip
Add sources of images, remove copyrighted image
-rw-r--r--mitmproxy/contentviews/image/image_parser.py4
-rw-r--r--test/mitmproxy/contentviews/test_image.py2
-rw-r--r--test/mitmproxy/contentviews/test_image_parser.py30
-rw-r--r--test/mitmproxy/data/all.jpegbin0 -> 230334 bytes
-rw-r--r--test/mitmproxy/data/image-err1.jpgbin82674 -> 0 bytes
-rw-r--r--test/mitmproxy/data/image_parser/README.md17
-rw-r--r--test/mitmproxy/data/image_parser/all.jpegbin0 -> 230334 bytes
-rw-r--r--test/mitmproxy/data/image_parser/image-err1.jpgbin82674 -> 0 bytes
8 files changed, 42 insertions, 11 deletions
diff --git a/mitmproxy/contentviews/image/image_parser.py b/mitmproxy/contentviews/image/image_parser.py
index bcae0566..1ff3cff7 100644
--- a/mitmproxy/contentviews/image/image_parser.py
+++ b/mitmproxy/contentviews/image/image_parser.py
@@ -73,10 +73,8 @@ def parse_jpeg(data: bytes) -> Metadata:
if segment.marker._name_ == 'com':
parts.append(('comment', str(segment.data)))
if segment.marker._name_ == 'app1':
- try:
+ if hasattr(segment.data, 'body'):
for field in segment.data.body.data.body.ifd0.fields:
if field.data is not None:
parts.append((field.tag._name_, field.data.decode('UTF-8').strip('\x00')))
- except AttributeError:
- pass
return parts
diff --git a/test/mitmproxy/contentviews/test_image.py b/test/mitmproxy/contentviews/test_image.py
index 9e7e28f5..e3dfb714 100644
--- a/test/mitmproxy/contentviews/test_image.py
+++ b/test/mitmproxy/contentviews/test_image.py
@@ -8,7 +8,7 @@ def test_view_image():
for img in [
"mitmproxy/data/image.png",
"mitmproxy/data/image.gif",
- "mitmproxy/data/image-err1.jpg",
+ "mitmproxy/data/all.jpeg",
"mitmproxy/data/image.ico"
]:
with open(tutils.test_data.path(img), "rb") as f:
diff --git a/test/mitmproxy/contentviews/test_image_parser.py b/test/mitmproxy/contentviews/test_image_parser.py
index 1595bba5..3c8bfdf7 100644
--- a/test/mitmproxy/contentviews/test_image_parser.py
+++ b/test/mitmproxy/contentviews/test_image_parser.py
@@ -136,16 +136,32 @@ def test_parse_gif(filename, metadata):
('Size', '717 x 558 px')
],
# check multiple segments
- "mitmproxy/data/image_parser/image-err1.jpg": [
+ "mitmproxy/data/image_parser/all.jpeg": [
('Format', 'JPEG (ISO 10918)'),
('jfif_version', '(1, 1)'),
- ('jfif_density', '(72, 72)'),
+ ('jfif_density', '(300, 300)'),
('jfif_unit', '1'),
- ('image_description', '<<enter caption here>> on December 4, 2009 in Washington, DC.'),
- ('make', 'Canon'), ('model', 'Canon EOS-1D Mark III'),
- ('artist', 'Alex Wong'),
- ('primary_chromaticities', '@\x00\x00\x00d'),
- ('copyright', '2009 Getty Images')
+ ('comment', 'b\'BARTOLOMEO DI FRUOSINO\\r\\n(b. ca. 1366, Firenze, d. 1441, '
+ 'Firenze)\\r\\n\\r\\nInferno, from the Divine Comedy by Dante (Folio 1v)'
+ '\\r\\n1430-35\\r\\nTempera, gold, and silver on parchment, 365 x 265 mm'
+ '\\r\\nBiblioth\\xe8que Nationale, Paris\\r\\n\\r\\nThe codex in Paris '
+ 'contains the text of the Inferno, the first of three books of the Divine '
+ 'Comedy, the masterpiece of the Florentine poet Dante Alighieri (1265-1321).'
+ ' The codex begins with two full-page illuminations. On folio 1v Dante and '
+ 'Virgil stand within the doorway of Hell at the upper left and observe its '
+ 'nine different zones. Dante and Virgil are to wade through successive '
+ 'circles teeming with images of the damned. The gates of Hell appear in '
+ 'the middle, a scarlet row of open sarcophagi before them. Devils orchestrate'
+ ' the movements of the wretched souls.\\r\\n\\r\\nThe vision of the fiery '
+ 'inferno follows a convention established by <A onclick="return OpenOther'
+ '(\\\'/html/n/nardo/strozzi3.html\\\')" HREF="/html/n/nardo/strozzi3.html">'
+ 'Nardo di Cione\\\'s fresco</A> in the church of Santa Maria Novella, Florence.'
+ ' Of remarkable vivacity and intensity of expression, the illumination is '
+ 'executed in Bartolomeo\\\'s late style.\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n'
+ '--- Keywords: --------------\\r\\n\\r\\nAuthor: BARTOLOMEO DI FRUOSINO'
+ '\\r\\nTitle: Inferno, from the Divine Comedy by Dante (Folio 1v)\\r\\nTime-line:'
+ ' 1401-1450\\r\\nSchool: Italian\\r\\nForm: illumination\\r\\nType: other\\r\\n\''),
+ ('Size', '750 x 1055 px')
],
}.items())
def test_parse_jpeg(filename, metadata):
diff --git a/test/mitmproxy/data/all.jpeg b/test/mitmproxy/data/all.jpeg
new file mode 100644
index 00000000..ea5d8d0f
--- /dev/null
+++ b/test/mitmproxy/data/all.jpeg
Binary files differ
diff --git a/test/mitmproxy/data/image-err1.jpg b/test/mitmproxy/data/image-err1.jpg
deleted file mode 100644
index 1b251e6e..00000000
--- a/test/mitmproxy/data/image-err1.jpg
+++ /dev/null
Binary files differ
diff --git a/test/mitmproxy/data/image_parser/README.md b/test/mitmproxy/data/image_parser/README.md
new file mode 100644
index 00000000..c23409bf
--- /dev/null
+++ b/test/mitmproxy/data/image_parser/README.md
@@ -0,0 +1,17 @@
+# Sources of the images used
+
+## PNG
+
+`aspect.png` - http://pngimg.com/upload/water_PNG3290.png
+All other PNGs are from the [PNGTestSuite](http://www.schaik.com/pngsuite/)
+
+# GIF
+
+All the GIFs are from the Pillow repository [here](https://github.com/python-pillow/Pillow/tree/master/Tests/images)
+
+# JPEG
+
+`app1.jpeg` - https://commons.wikimedia.org/wiki/File:PT05_ubt.jpeg
+`all.jpeg` - https://commons.wikimedia.org/wiki/Category:Dante's_Inferno#/media/File:Bartolomeo_Di_Fruosino_-_Inferno,_from_the_Divine_Comedy_by_Dante_(Folio_1v)_-_WGA01339.jpg
+`comment.jpg` has been taken from [here](https://commons.wikimedia.org/wiki/File:JPEG_example_image.jpg) and has a comment added locally
+All other JPEGs are from the Pillow repository [here](https://github.com/python-pillow/Pillow/tree/master/Tests/images)
diff --git a/test/mitmproxy/data/image_parser/all.jpeg b/test/mitmproxy/data/image_parser/all.jpeg
new file mode 100644
index 00000000..ea5d8d0f
--- /dev/null
+++ b/test/mitmproxy/data/image_parser/all.jpeg
Binary files differ
diff --git a/test/mitmproxy/data/image_parser/image-err1.jpg b/test/mitmproxy/data/image_parser/image-err1.jpg
deleted file mode 100644
index 1b251e6e..00000000
--- a/test/mitmproxy/data/image_parser/image-err1.jpg
+++ /dev/null
Binary files differ