diladele / websafety

Simple and powerful web filter for HTTP and HTTPS traffic
https://www.diladele.com/websafety/
243 stars 24 forks source link

Some problems with russian charset #1201

Open ru-user opened 5 years ago

ru-user commented 5 years ago

Hi. If I insert a russian comment into field Squid Proxy / Settings / Default ACLs / Advanced ACLs the Web Safety does not restart with an error:

Restart FAILED

Exit code -

Exception - 'ascii' codec can't encode characters in position 21232-21236: ordinal not in range(128)

Program output

Errors / Exceptions

Traceback (most recent call last): File "/opt/websafety/var/console/frame/views.py", line 68, in post profile.generate() File "/opt/websafety/var/console/frame/models.py", line 51, in generate SquidGenerator(os.path.join(etc_dir, "squid")).generate() File "/opt/websafety/var/console/utility/generator.py", line 32, in generate self.generate_config(new_dir) File "/opt/websafety/var/console/squid/generator.py", line 142, in generate_config self.generate_config_acls(target_dir) File "/opt/websafety/var/console/squid/generator.py", line 237, in generate_config_acls context File "/opt/websafety/var/console/squid/generator.py", line 716, in generate_template_with_context fout.write(data) UnicodeEncodeError: 'ascii' codec can't encode characters in position 21232-21236: ordinal not in range(128)

And also if there are russian characters in the computer names then an error is displayed in the field Squid Proxy / General / Runtime Info / Client List: 'utf-8' codec can't decode byte 0x8f in position 18489: invalid start byte Traceback (most recent call last): File "/opt/websafety/var/console/_domain/squid/squid_client.py", line 96, in get_str result = self.get_str_unsafe(request) File "/opt/websafety/var/console/_domain/squid/squid_client.py", line 115, in get_str_unsafe (exit_code, stdout, stderr) = Command().run(args) File "/opt/websafety/var/console/_domain/utils/command.py", line 38, in run stdout = stdout.decode("utf-8") UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8f in position 18489: invalid start byte

The command squidclient -h 127.0.0.1 cache_object://127.0.0.1/client_list displays such data:

HTTP/1.1 200 OK Server: squid/4.8 Mime-Version: 1.0 Date: Mon, 16 Sep 2019 03:16:43 GMT Content-Type: text/plain;charset=utf-8 Expires: Mon, 16 Sep 2019 03:16:43 GMT Last-Modified: Mon, 16 Sep 2019 03:16:43 GMT X-Cache: MISS from proxy.local X-Cache-Lookup: MISS from proxy.local:3128 Via: 1.1 proxy.local (squid/4.8) Connection: close

Cache Clients: Address: 10.10.39.48 Name: Denis-...ceh12b.local Currently established connections: 4 ICP Requests 0 HTTP Requests 31806 NONE 15833 50% TCP_HIT 1 0% TCP_MISS 1279 4% TCP_REFRESH_UNMODIFI 41 0% TCP_REFRESH_MODIFIED 86 0% TCP_IMS_HIT 366 1% TCP_MEM_HIT 81 0% TCP_DENIED 832 3% TCP_TUNNEL 13287 42% TOTALS ICP : 0 Queries, 0 Hits ( 0%) HTTP: 1805597 Requests, 12054 Hits ( 1%)

The command nslookup 10.10.39.48 displays such data in CP866 encoding: Name: Denis-ПК.ceh12b.local Address: 10.10.39.48

Best regards

ra-at-diladele-com commented 5 years ago

Hello, yes it is recommended to use only ascii for now in comments, fields. Postponing till the next versions, lets see what is better to do.