From 24a376980919d67c45f369817f8fef6b8c3b574a Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Thu, 5 Nov 2015 19:25:19 +0800 Subject: [PATCH] fix http_simple a bug of urlencode length --- shadowsocks/obfsplugin/http_simple.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shadowsocks/obfsplugin/http_simple.py b/shadowsocks/obfsplugin/http_simple.py index 8144aa8..ad782ee 100644 --- a/shadowsocks/obfsplugin/http_simple.py +++ b/shadowsocks/obfsplugin/http_simple.py @@ -133,10 +133,14 @@ class http_simple(plain.plain): hex_items = lines[0].split(b'%') if hex_items and len(hex_items) > 1: for index in range(1, len(hex_items)): - if len(hex_items[index]) != 2: + if len(hex_items[index]) < 2: + ret_buf += binascii.unhexlify('0' + hex_items[index]) + break + elif len(hex_items[index]) > 2: ret_buf += binascii.unhexlify(hex_items[index][:2]) break - ret_buf += binascii.unhexlify(hex_items[index]) + else: + ret_buf += binascii.unhexlify(hex_items[index]) return ret_buf return b''