From b961a3fb0a6ec764312e1bdd886cfd944ca9489d Mon Sep 17 00:00:00 2001 From: HelloZeroNet Date: Sat, 24 Oct 2015 13:57:46 +0200 Subject: [PATCH] Rev480, Skip non-ascii files at signing, Fix gevent 1.1alpha compatibility --- src/Config.py | 2 +- src/Content/ContentManager.py | 6 ++++++ .../content.json | 8 ++++---- .../content.json | 4 ++-- .../content.json | 4 ++-- .../data/users/content.json | 4 ++-- .../data/zeroblog.db | Bin 53248 -> 53248 bytes src/main.py | 12 +++++------- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Config.py b/src/Config.py index 15ed822b..6e0b4219 100644 --- a/src/Config.py +++ b/src/Config.py @@ -8,7 +8,7 @@ class Config(object): def __init__(self, argv): self.version = "0.3.2" - self.rev = 477 + self.rev = 480 self.argv = argv self.action = None self.createParser() diff --git a/src/Content/ContentManager.py b/src/Content/ContentManager.py index abcec3ce..bba537c1 100644 --- a/src/Content/ContentManager.py +++ b/src/Content/ContentManager.py @@ -259,6 +259,9 @@ class ContentManager(object): def hashFiles(self, dir_inner_path, ignore_pattern=None, optional_pattern=None): files_node = {} files_optional_node = {} + if not re.match("^[a-zA-Z0-9_\.\+-/]*$", dir_inner_path): + ignored = True + self.log.error("- [ERROR] Only ascii encoded directories allowed: %s" % dir_inner_path) for file_relative_path in self.site.storage.list(dir_inner_path): file_name = helper.getFilename(file_relative_path) @@ -270,6 +273,9 @@ class ContentManager(object): ignored = True elif file_name.startswith("."): ignored = True + elif not re.match("^[a-zA-Z0-9_\.\+\-/]+$", file_relative_path): + ignored = True + self.log.error("- [ERROR] Only ascii encodes filenames allowed: %s" % file_relative_path) elif optional_pattern and re.match(optional_pattern, file_relative_path): optional = True diff --git a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/content.json b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/content.json index dd20db92..9c3e5cee 100644 --- a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/content.json +++ b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/content.json @@ -120,15 +120,15 @@ "signers_required": 1 } }, - "modified": 1443645832.748, + "modified": 1445621835.637, "optional": "(data/img/zero.*|data/optional.txt)", "sign": [ - 33155653220731268227776289017011639520872180216646876377169089096034035969487, - 36744504416132878244552522451563313660303086381031784548929582417244124447603 + 47850243869989268528712520567298442290019403318054234291033274718437879648427, + 27185986573270415412620789926197549872389185391900755638388274126359800685380 ], "signers_sign": "HDNmWJHM2diYln4pkdL+qYOvgE7MdwayzeG+xEUZBgp1HtOjBJS+knDEVQsBkjcOPicDG2it1r6R1eQrmogqSP0=", "signs": { - "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "HP+qomOGy0hTFX1HjHv8iQIL6E22qNynb+IijEblL2lm8SgsyiOxKGaVkD6/eE6xYGeYHSnhSii2Gw/04z3okNM=" + "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G84Wz60kiTpSJJYR9CFyIVHEQVzVB7bCXk+G+v6w2Mkv3a/2R+XNkV26qn7Tj4DHYGs5Xxi7jeXgPHTXzAhsQ+s=" }, "signs_required": 1, "title": "ZeroBlog", diff --git a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json index 3bb3929f..dcdbc18f 100644 --- a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json +++ b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json @@ -14,9 +14,9 @@ "size": 1606 } }, - "modified": 1443645834.763, + "modified": 1445621840.488, "optional": ".*\\.(jpg|png|gif)", "signs": { - "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "HD+/5Jmew6BotfeWsfpTFKXUVIY5MyjKQx5KRnT6WO0nMBLxaI6/sTb+6ZXq0tXjXNkmlt36/UICYQcYQjCRhkY=" + "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G/I/c+fbVkmv79Bcok+QZU9E5P4ruG5mxrfQqbc+KmUcf6kYKWM5L/dZERMRGl3dUiTe4ueHnSbgG8HsTz9UmHI=" } } \ No newline at end of file diff --git a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json index ada2c7ac..1b12adf4 100644 --- a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json +++ b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json @@ -8,8 +8,8 @@ "size": 168 } }, - "modified": 1443645835.157, + "modified": 1445621840.892, "signs": { - "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "HNIXDWV1kpqKtsJ+yrNKLvks/FDYIpVmx7xgkXPJ6NZiajCMHrgEwLH9QRiq6rs3nOCs0P08eRhlgZLvC+3U6ps=" + "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "HDPcGHXKRufZx3eo1u0mH0xzaF+Uf05dNApdT2l+7GhZHXUqGv0VMShyeGGpiGOO9U55wEgPQNSoh9YY/S0WXI8=" } } \ No newline at end of file diff --git a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/content.json b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/content.json index b3894239..ea4deb0c 100644 --- a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/content.json +++ b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/users/content.json @@ -1,9 +1,9 @@ { "files": {}, "ignore": ".*", - "modified": 1443645833.247, + "modified": 1445621836.165, "signs": { - "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G2EcaEKdzzfbpRITDcaBajNwjaIIJW3zp1YQGIMJcxfw3tLnn6uv/goImvbzvuTXKkl5fQKmBowK2Bg1xXJ3078=" + "1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT": "G1CD1I6FDKfI5iCtu3s5gNQZJYuy60a5fCa/iFTEiyjF2LFLo3dhndpodVksrdgE0NVRfEmVa9sKYQf5MjPtFPM=" }, "user_contents": { "cert_signers": { diff --git a/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/zeroblog.db b/src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT/data/zeroblog.db index a22146e792a78778bc46ceaea7f95e94f2943345..aa415555ee7ce303c4a1354cdad2605483a92e69 100644 GIT binary patch delta 857 zcmX|=Ur5tY6vyxR-Fw~CDa}otZgW%TzvTcXrvkrAy*Br%e^R(1FSb zoz6?>ygInvK(C^A(#zElwL~4^C+dj?B0w|}L86stBCO4%LP8I2Awp`rqYM`}FY>%% zoy~xG#vL$^mhdz9|Be@aWY(p~2FXAgA>;eRIgc8CGOQLiucGWcGBO=pfE~r!F}M8P zkXsm?F%=Y#aO}oILs{M*Kvs<9V^HG&dOrZP4u8|T`!VC~+ zbi!147Q>^b0pm|cj2r+z13#Q+0lh;Y`5XNcJ5-SrDKV<6+8CW}s#;guQ{C7$^1(0z zOEQ)OH~pHxWMYt~2zC8omw-qWrv0r58djJV9~)cB&P>uH4qA_t$$Ep zOnJQskMbx1nsf(8mo+5(sB18qDf<43N@`2y`eBbwde$Shk!^|8`20+^% zZQjMswOaE9-{Jy$oU>>b0{#YF0nknWts_IDqsee0l^hHAB~y)O2Yo{(2>dnRrCRNf z1ZaRtr4-_Z!cF{z8|;aEM!V7Ma%h8c1S~~dJ~(dOC-Sz3esdw70;snB?tyfyRdya} z5jrBm;bx(|Nr*NIhr+_a2B9q^v<8HhdLdFLG}j1CKB3VogsX)Hk8oh05ULV_dxd~Y zs4urzw@2_hgjyriQ2Bd53O?TH2Io>A661SK4k#$}LxE#71ONLy^}Vuu9zan+QA)GG z#dqhl%e%X36c`($EjGPd`d@NI!HNv^HSo%-Ztc`6t01GY61&UU{+rsmU;bhGxQ$D1 z3|X`MY3fWBuP+CY&5J>hX?5`QVoGzxvmMNtd5Pp#xre;K>xF=3ngcRwLa7Nk@eWTs zzK#as3gXgTCvbe`gU-=3oVaCz{R3 z7Lp9?DAVO_e0qs?hk|Z}ZW)S3>mK-NIwjG?bY5m~+Q{FOlq%U6<+*gS7vb1nf*hq} diff --git a/src/main.py b/src/main.py index 61d38792..48e097dd 100644 --- a/src/main.py +++ b/src/main.py @@ -7,7 +7,11 @@ import logging # Third party modules import gevent from gevent import monkey - +if "patch_subprocess" in dir(monkey): + monkey.patch_all(thread=False, subprocess=False) +else: + monkey.patch_all(thread=False) +# Not thread: pyfilesystem and systray icon, Not subprocess: Gevent 1.1+ update_after_shutdown = False # If set True then update and restart zeronet after main loop ended @@ -56,8 +60,6 @@ if config.debug: else: console_log.setLevel(logging.INFO) # Display only important info to console -monkey.patch_all(thread=False) # Not thread: pyfilesystem and system tray icon not compatible - # Load plugins from Plugin import PluginManager PluginManager.plugin_manager.loadPlugins() @@ -80,8 +82,6 @@ if config.proxy: SocksProxy.monkeyPath(*config.proxy.split(":")) - - # -- Actions -- @PluginManager.acceptPlugins @@ -213,7 +213,6 @@ class Actions(object): def sitePublish(self, address, peer_ip=None, peer_port=15441, inner_path="content.json"): global file_server - from Site import Site from Site import SiteManager from File import FileServer # We need fileserver to handle incoming file requests @@ -285,7 +284,6 @@ class Actions(object): print "Response time: %.3fs" % (time.time() - s) raw_input("Check memory") - def peerCmd(self, peer_ip, peer_port, cmd, parameters): logging.info("Opening a simple connection server") global file_server