git://git.nikiroo.be
/
nikiroo-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
44f134a
)
do not allow empty cover images
author
Niki Roo
<niki@nikiroo.be>
Fri, 15 May 2020 11:00:21 +0000
(13:00 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Fri, 15 May 2020 11:00:21 +0000
(13:00 +0200)
src/be/nikiroo/fanfix/library/LocalLibrary.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/library/WebLibrary.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/searchable/Fanfiction.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/searchable/MangaLel.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/supported/BasicSupportHelper.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/supported/BasicSupportImages.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/supported/Cbz.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/supported/Epub.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/supported/FimfictionApi.java
patch
|
blob
|
blame
|
history
src/be/nikiroo/fanfix/supported/MangaLel.java
patch
|
blob
|
blame
|
history
diff --git
a/src/be/nikiroo/fanfix/library/LocalLibrary.java
b/src/be/nikiroo/fanfix/library/LocalLibrary.java
index 7220a3951de137f99a4a11ecc7e5f5b119abb3c1..f655d4d03bb43b5df69d00fc8b30b2adbad6c113 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/LocalLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/LocalLibrary.java
@@
-254,7
+254,13
@@
public class LocalLibrary extends BasicLibrary {
in = new FileInputStream(cover);
try {
synchronized (lock) {
in = new FileInputStream(cover);
try {
synchronized (lock) {
- sourceCovers.put(source, new Image(in));
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ sourceCovers.put(source, img);
}
} finally {
in.close();
}
} finally {
in.close();
@@
-298,7
+304,13
@@
public class LocalLibrary extends BasicLibrary {
in = new FileInputStream(cover);
try {
synchronized (lock) {
in = new FileInputStream(cover);
try {
synchronized (lock) {
- authorCovers.put(author, new Image(in));
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ authorCovers.put(author, img);
}
} finally {
in.close();
}
} finally {
in.close();
diff --git
a/src/be/nikiroo/fanfix/library/WebLibrary.java
b/src/be/nikiroo/fanfix/library/WebLibrary.java
index 0f2510dd544218279d8ddcaa1beae3ad097d631c..9af38e2b6bd1c7ccb565ca6f244e31ef42f40746 100644
(file)
--- a/
src/be/nikiroo/fanfix/library/WebLibrary.java
+++ b/
src/be/nikiroo/fanfix/library/WebLibrary.java
@@
-174,6
+174,7
@@
public class WebLibrary extends BasicLibrary {
try {
Image img = new Image(in);
if (img.getSize() > 0) {
try {
Image img = new Image(in);
if (img.getSize() > 0) {
+ img.close();
return img;
}
return img;
}
@@
-189,6
+190,7
@@
public class WebLibrary extends BasicLibrary {
try {
Image img = new Image(in);
if (img.getSize() > 0) {
try {
Image img = new Image(in);
if (img.getSize() > 0) {
+ img.close();
return img;
}
return img;
}
@@
-204,6
+206,7
@@
public class WebLibrary extends BasicLibrary {
try {
Image img = new Image(in);
if (img.getSize() > 0) {
try {
Image img = new Image(in);
if (img.getSize() > 0) {
+ img.close();
return img;
}
return img;
}
diff --git
a/src/be/nikiroo/fanfix/searchable/Fanfiction.java
b/src/be/nikiroo/fanfix/searchable/Fanfiction.java
index e2fba1ff404f17d2a23bc18defbc2b03d7a425e3..cbc927bcc2d981b028311be59fa2d1ba7c152542 100644
(file)
--- a/
src/be/nikiroo/fanfix/searchable/Fanfiction.java
+++ b/
src/be/nikiroo/fanfix/searchable/Fanfiction.java
@@
-287,7
+287,13
@@
class Fanfiction extends BasicSearchable {
try {
InputStream in = Instance.getInstance().getCache().open(new URL(coverUrl), getSupport(), true);
try {
try {
InputStream in = Instance.getInstance().getCache().open(new URL(coverUrl), getSupport(), true);
try {
- meta.setCover(new Image(in));
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ meta.setCover(img);
} finally {
in.close();
}
} finally {
in.close();
}
diff --git
a/src/be/nikiroo/fanfix/searchable/MangaLel.java
b/src/be/nikiroo/fanfix/searchable/MangaLel.java
index 5ba21a0e1ce25b799dc0b9a6d14d3a447135ef01..354edb435ef281a0dab3a31f55218f63c2ab6586 100644
(file)
--- a/
src/be/nikiroo/fanfix/searchable/MangaLel.java
+++ b/
src/be/nikiroo/fanfix/searchable/MangaLel.java
@@
-140,7
+140,13
@@
class MangaLel extends BasicSearchable {
InputStream in = Instance.getInstance().getCache().open(new URL(coverUrl), getSupport(),
true);
try {
InputStream in = Instance.getInstance().getCache().open(new URL(coverUrl), getSupport(),
true);
try {
- meta.setCover(new Image(in));
+ Image ii = new Image(in);
+ if (ii.getSize() == 0) {
+ ii.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ meta.setCover(ii);
} finally {
in.close();
}
} finally {
in.close();
}
diff --git
a/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java
b/src/be/nikiroo/fanfix/supported/BasicSupportHelper.java
index 7768052cafc758094e38c1968f5919f6b853b8bc..f3c30bc9657dfe1a70555d8104cd591ad3bf1523 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/BasicSupportHelper.java
+++ b/
src/be/nikiroo/fanfix/supported/BasicSupportHelper.java
@@
-85,7
+85,13
@@
public class BasicSupportHelper {
InputStream in = null;
try {
in = Instance.getInstance().getCache().open(url, support, true);
InputStream in = null;
try {
in = Instance.getInstance().getCache().open(url, support, true);
- return new Image(in);
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ return img;
} catch (IOException e) {
} finally {
if (in != null) {
} catch (IOException e) {
} finally {
if (in != null) {
diff --git
a/src/be/nikiroo/fanfix/supported/BasicSupportImages.java
b/src/be/nikiroo/fanfix/supported/BasicSupportImages.java
index 576cb17e78bb3abfe845a1b053df47618636e5c6..f56b50c2b67a6dd9f5a4b1e0de572767d0a42dde 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/BasicSupportImages.java
+++ b/
src/be/nikiroo/fanfix/supported/BasicSupportImages.java
@@
-55,7
+55,13
@@
public class BasicSupportImages {
InputStream in = null;
try {
in = Instance.getInstance().getCache().open(url, support, true);
InputStream in = null;
try {
in = Instance.getInstance().getCache().open(url, support, true);
- return new Image(in);
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ return img;
} catch (IOException e) {
} finally {
if (in != null) {
} catch (IOException e) {
} finally {
if (in != null) {
diff --git
a/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java
b/src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java
index a50ee3cf48a962a38b5ebe52b33184c956169ffd..40ff3fc027c7e52beca3426017e1a6a58972fbbe 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java
+++ b/
src/be/nikiroo/fanfix/supported/BasicSupport_Deprecated.java
@@
-651,7
+651,13
@@
public abstract class BasicSupport_Deprecated extends BasicSupport {
InputStream in = null;
try {
in = Instance.getInstance().getCache().open(url, getSupport(url), true);
InputStream in = null;
try {
in = Instance.getInstance().getCache().open(url, getSupport(url), true);
- return new Image(in);
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ return img;
} catch (IOException e) {
} finally {
if (in != null) {
} catch (IOException e) {
} finally {
if (in != null) {
diff --git
a/src/be/nikiroo/fanfix/supported/Cbz.java
b/src/be/nikiroo/fanfix/supported/Cbz.java
index 7fe496d97ea8acb9e8869bb41c37d6723e19a636..a5391d07575e9f6102ab531e4a756c1be718f711 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/Cbz.java
+++ b/
src/be/nikiroo/fanfix/supported/Cbz.java
@@
-97,7
+97,13
@@
class Cbz extends Epub {
if (imageEntry) {
String uuid = meta.getUuid() + "_" + entry.getName();
try {
if (imageEntry) {
String uuid = meta.getUuid() + "_" + entry.getName();
try {
- images.put(uuid, new Image(zipIn));
+ Image img = new Image(zipIn);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ images.put(uuid, img);
} catch (Exception e) {
Instance.getInstance().getTraceHandler().error(e);
}
} catch (Exception e) {
Instance.getInstance().getTraceHandler().error(e);
}
diff --git
a/src/be/nikiroo/fanfix/supported/Epub.java
b/src/be/nikiroo/fanfix/supported/Epub.java
index 965a27affda88bfe8919e744b80962f58c3aa465..783d724e36aaa84e822f1fb5f4c6590371a4a8fd 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/Epub.java
+++ b/
src/be/nikiroo/fanfix/supported/Epub.java
@@
-128,7
+128,13
@@
class Epub extends InfoText {
// Cover
if (getCover() && cover == null) {
try {
// Cover
if (getCover() && cover == null) {
try {
- cover = new Image(zipIn);
+ Image img = new Image(zipIn);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ cover = img;
} catch (Exception e) {
Instance.getInstance().getTraceHandler()
.error(e);
} catch (Exception e) {
Instance.getInstance().getTraceHandler()
.error(e);
diff --git
a/src/be/nikiroo/fanfix/supported/FimfictionApi.java
b/src/be/nikiroo/fanfix/supported/FimfictionApi.java
index 43d01d19494f616c6811e5757da4a6f2e14c83cc..e6dd6118721b93aec36c0d7c734faad1c6d9a95b 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/FimfictionApi.java
+++ b/
src/be/nikiroo/fanfix/supported/FimfictionApi.java
@@
-147,7
+147,13
@@
class FimfictionApi extends BasicSupport {
try {
InputStream in = Instance.getInstance().getCache().open(coverImageUrl, null, true);
try {
try {
InputStream in = Instance.getInstance().getCache().open(coverImageUrl, null, true);
try {
- meta.setCover(new Image(in));
+ Image img = new Image(in);
+ if (img.getSize() == 0) {
+ img.close();
+ throw new IOException(
+ "Empty image not accepted");
+ }
+ meta.setCover(img);
} finally {
in.close();
}
} finally {
in.close();
}
diff --git
a/src/be/nikiroo/fanfix/supported/MangaLel.java
b/src/be/nikiroo/fanfix/supported/MangaLel.java
index de0b871331ef313b6be628c382c9487f281b5c3e..5910a371aedf7272e546ec7170b508516879ced1 100644
(file)
--- a/
src/be/nikiroo/fanfix/supported/MangaLel.java
+++ b/
src/be/nikiroo/fanfix/supported/MangaLel.java
@@
-138,11
+138,17
@@
class MangaLel extends BasicSupport {
if (img != null) {
String coverUrl = img.absUrl("src");
if (img != null) {
String coverUrl = img.absUrl("src");
- InputStream coverIn;
try {
try {
- coverIn = Instance.getInstance().getCache().open(new URL(coverUrl), this, true);
+ InputStream coverIn = Instance.getInstance().getCache()
+ .open(new URL(coverUrl), this, true);
try {
try {
- return new Image(coverIn);
+ Image ii = new Image(coverIn);
+ if (ii.getSize() == 0) {
+ ii.close();
+ throw new IOException("Empty image not accepted");
+ }
+
+ return ii;
} finally {
coverIn.close();
}
} finally {
coverIn.close();
}