Bug fixes and features - binrc - 2024-01-26 02:53:50 - cc-by-nc-sa

Bug fixes and features


Today I worked on fixing the major issue with posting: if your post fails to pass the constraint checks it will be lost to time. Browsers do not cache the contents of the tag or tags so directing users to a page that tells them their post is not acceptable without any ability to correct it (despite the fact that it is still available to php) is a glaring oversight. This website has three main constraints:

  1. posts must be 2000 characters long or longer
  2. comments must be unique and 500 characters long or longer.
  3. all posts and comments must be unique (a sha256sum is created and stored to ensure unique submissions only)

In order to correct the first and second issue, I added the easily overlooked html tag attribute of minlength=2000 and minlength=500 to the post form and comment form respectively. This prevents the user from submitting the form if the post is too short. Of course, the user could get around this form restriction using the browser's web dev tools but it's enforced server side so people trying to break things is not a serious issue.

The third issue was harder to correct. Obviously it would be possible to notify the user that his post is not unique (because the hash of his post matches an existing hash in the database) using ajax. I do not want to include javascript if I can help it so I came up with another solution.

Previously, the php script would simply die(); if the post was not unique. In order to fix this, I added a failsafe. If the user's post is not unique, a form will be shown on the doaddpost.php page with his content inserted. On submit, this form will send it's data to doaddpost.php . The user can repeatedly attempt to submit the post until it becomes viable.

All of the above applies to the post editing system and the comment adding system.

export options


I added two options that allow for the export of the user's data. The first is a simple csv export. A csv is created of the user's posts with the title, date, and content as columns. This content column is unrendered markdown.

The second option exports the posts in a .zip archive. Each post is written to a different file with yaml style markdown metadata headers. Currently, the markdown processor outputs it's results directly and does not use a buffer of any sort so it is near impossible to generate a .zip archive with standalone html files using this markdown processor. I have forgotten how it works because I wrote it quite a while ago. Markdown is good enough for now I think.

This post has no votes.