[libhttpseverywhere] context: avoid critical errors on empty rule files



commit 72644767582e521c3692e94a119d911b8fab0735
Author: grindhold <grindhold gmx net>
Date:   Fri Jan 19 22:03:19 2018 +0100

    context: avoid critical errors on empty rule files
    
    when a ruleset file was empty, the json parser tried to parse it
    and failed. now we check wheter the file is 0 bytes long and disqualify
    it if so. now the most severe message that will be shown is a warning

 src/context.vala |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/src/context.vala b/src/context.vala
index 4cb94c7..64345d2 100644
--- a/src/context.vala
+++ b/src/context.vala
@@ -117,6 +117,10 @@ namespace HTTPSEverywhere {
             foreach (string dp in datapaths) {
                 try {
                     File f = File.new_for_path(dp);
+                    FileInfo fi = f.query_info("standard::*", FileQueryInfoFlags.NONE);
+                    if (fi.get_size() == 0) {
+                        continue;
+                    }
                     FileInputStream fis = yield f.read_async(Priority.DEFAULT, cancellable);
                     DataInputStream dis = new DataInputStream(fis);
                     yield parser.load_from_stream_async(dis, cancellable);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]