Welcome to One Week Hack!

Fifty Little Projects in Fifty Weeks

That did not last long.

By Lawrence Statton — Aug 22, 2023 3:44 pm
Category: Meta Perl Postfix

I intend to step away from working on the blog software for a few days, and get back to Android programming.

Hello, Diabolical Industries? I have a truckload of good intentions here, in case you want a new road.

One of the negative aspects of my mania is: When I get the urge to work on something, it is near impossible to concentrate on anything else, so I may as well write the code that I need to write. The sooner it is finished, the sooner I move on to something else.

Today, that was something for this very site that I intended to write no sooner than two or three weeks down the road. If I ever have any readers, they will want to leave their pithy commentary on my posts. Most blog software bring up some kind of Javascript-based editor, and you post your response within the confines of the four corners of the web page. I had a different idea a decade ago, and only recently decided to actually implement it. You probably have an editor that you like and that you use every day in your mail client.

When commenting becomes an option, there will be some kind of javascript hooziwatzit that will generate an ad-hoc time-limited mailto:content+UUID@1weekhack.com URL which is correlated to the content upon which you are commenting. The code as written uses fifteen minutes, but that is obviously a parameter that can be altered.

Another potential benefit of this: My instinct says that most comment-spam is simple scrape-and-post code. Until my idea becomes wide-spread, it is not worth the bottom feedersĀ“ time to implement an email component. Time will tell.

The mechanics: There exists a table in the database that links content elements to these opaque UUID tokens and their expiration timestamp.

For good-and-sufficient-reason I settled up on Postfix for my mail needs some years ago, being dragged kicking and screaming from my Bat Book by an employer who simply demanded we would not use sendmail.

It started with writing the program that will read in the mail on a pipe, and parse it using the Perl library MIME::Parser. I then extract the important-to-me headers (To: , From:, and Subject:) and wrote a little recursive subroutine to find the first text/plain entity in the mail.

The plain text is then wrapped in very trivial XHTML, and a row is added to the comment table in the database, with the name (but not email address) of the author, the subject, and which article it is connected to. The XHTML is written into the spool directory, and for the moment is duly ignored.

Then it was time to do battle with Postfix. I learned how to configure a transport_map, and add a new transport mechanism to my master.cf file, named Gulpo. (Named for the SMBC meme "Gulpo: The fish who eats concepts".)

Biggest hassles were wrestling directory permissions into submission. I have what I think is a fairly healthy paranoia about software that has the power to write to the filesystem based on external sources, so it is important to carefully control where those processes can write. I am not so paranoid that I make everything live in a chroot jail, but it probably would behoove me to become adept in that at some point.

Fifteen mintues of testing with a corpus of different randomly-selected emails from my saved-mail folder, and I had it working to the point that I was ready to call it Alpha Release Quality

Search
Side Widget
You can put anything you want inside of these side widgets. They are easy to use, and feature the Bootstrap 5 card component!