Zeronet: Files with "!" in the name are not added to content.json

Created on 11 Aug 2019  ยท  1Comment  ยท  Source: HelloZeroNet/ZeroNet

Step 1: Please describe your environment

  • ZeroNet version: 0.7.0 rev4172
  • Operating system: W7x64
  • Web browser: N/A
  • Tor status: N/A
  • Opened port: N/A
  • Special configuration: No

Step 2: Describe the problem:

Files that contain ! (exclamation mark) in the file name are not added to content.json.

Note: This seems to apply to a few other characters too, including but not limited to ' (apostrophe) and & (ampersand)

Steps to reproduce:

  1. Create blank site
  2. Create a few files with and without an exclamation mark in the name
  3. Set site name and description, then sign and publish the site

Observed Results:

When setting the site name and description, the directory is scanned for files, and they are added to the content.json index. Files containing an exclamation mark are not added to the file and thus are not shared with others.

The debug log contains lines like these (some information has been redacted by me):

[2019-08-11 โ–ˆโ–ˆโ–ˆ] ERROR    Site:โ–ˆโ–ˆโ–ˆ - [ERROR] Invalid filename: Test !.txt
[2019-08-11 โ–ˆโ–ˆโ–ˆ] INFO     Site:โ–ˆโ–ˆโ–ˆ - [SKIPPED] Test !.txt

Expected Results:

No seemingly arbitrarily chosen file name rules in place. Any file name made up of a valid file name character sequence should be added to the content.json file.

Related problems

Files/directories that start with . or end in -old or -new are hardcoded to be excluded too.

This puts a huge dampener on sharing git repositories or creating the .well-known folder. (See RFC 5785)

Notes

The offending location for the character selection seems to be https://github.com/HelloZeroNet/ZeroNet/blob/5a746769d01db58d54ff121e784fbf87374a89f3/src/Content/ContentManager.py#L603

Most helpful comment

I want to add here that it took me hours to find this problem because the local client that hosts the files is totally happy delivering them to the browser regardless if the names are considered valid.

If you need a regex for all valid file names: ^[^\x00-\x1F\x22\x2A\x2F\x3A\x3C\x3E\x3F\x5C\x7C]+$

Without hex where avoidable: ^[^\x00-\x1F"*/:<>?\\|]+$

>All comments

I want to add here that it took me hours to find this problem because the local client that hosts the files is totally happy delivering them to the browser regardless if the names are considered valid.

If you need a regex for all valid file names: ^[^\x00-\x1F\x22\x2A\x2F\x3A\x3C\x3E\x3F\x5C\x7C]+$

Without hex where avoidable: ^[^\x00-\x1F"*/:<>?\\|]+$

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaniellMesquita picture DaniellMesquita  ยท  3Comments

unsystemizer picture unsystemizer  ยท  4Comments

imachug picture imachug  ยท  3Comments

jerry-wolf picture jerry-wolf  ยท  4Comments

sergei-bondarenko picture sergei-bondarenko  ยท  3Comments