open
https://gitlab.synchro.net/main/sbbs/-/work_items/1290
## Summary
When a file is uploaded, Synchronet currently reads a SAUCE record only from the *description file extracted from the upload* (`FILE_ID.DIZ` / `DESC.SDI`), and only when the directory has the DIZ option (`DIR_DIZ`) enabled. A SAUCE record appended to the **uploaded file itself** is ignored.
Proposal: also read the uploaded file's own SAUCE record and use its Title, Author, and Group to populate the file's description, `SMB_AUTHOR`, and `SMB_AUTHOR_ORG` header fields.
## Current behavior
- `read_diz()` (`src/sbbs3/filedat.c`) calls `sauce_fread_charinfo()` on the extracted DIZ file.
- `file_sauce_hfields()` (`src/sbbs3/filedat.c`) then stores SAUCE Author as `SMB_AUTHOR`, Group as `SMB_AUTHOR_ORG`, and Title as `SMB_FILEDESC` (only if no description exists yet).
- This logic is repeated in three upload paths:
- Terminal Server uploads: `src/sbbs3/upload.cpp`
- FTP uploads: `src/sbbs3/ftpsrvr.cpp`
- JS `FileBase.add()` (e.g. `addfiles.js`): `get_diz()` in `src/sbbs3/js_filebase.cpp`
- The stored fields are already used downstream: the file info screen (`FiAuthor`/`FiGroup`), `@FILE_AUTHOR@`/`@FILE_GROUP@`, file find/search (`FL_FIND` matches author and group), and the JS `author`/`author_org` file properties.
## Why it's useful
- **Standalone art files.** `.ANS`/`.ASC`/`.XB`/`.BIN`/`.ICE` files are often uploaded individually (not in an archive), especially to art directories. They currently get no description/author/group unless the uploader types one, even though the file itself says who made it.
- **The file's own SAUCE is the more accurate source.** The SAUCE on a pack's `FILE_ID.DIZ` usually credits the artist who drew the DIZ (often the pack group's DIZ artist), not the author of the content. A file's own SAUCE describes that file.
- **SAUCE is not limited to character art.** It defines data types for Audio (MOD/S3M/XM/IT; the tracker scene tags heavily), Bitmap (GIF/PNG/JPG), XBin, Executable, and Archive. A ZIP can carry a trailing SAUCE record, since ZIP readers tolerate appended data. So the check makes sense for *every* upload, not only non-archives.
- **Cheap and low-risk.** It costs one seek plus a 128-byte read from the end of a file the upload path already reads in full for hashing. False positives are very unlikely: `sauce_fread_record()` requires the `SAUCE00` ID, the EOF separator, and (when comments are present) the `COMNT` block ID.
- **No new display code needed.** The header fields and all their consumers already exist.
## Suggested implementation
1. **Generic SAUCE reader.** `sauce_fread_charinfo()` (`src/sbbs3/sauce.c`) returns false for any data type other than Character. Add a sibling (e.g. `sauce_fread_info()`) that returns title/author/group/date for *any* data type. Alternatively, have `file_sauce_hfields()` take a `sauce_record_t` directly.
2. **One shared helper, three callers.** Add a single function in `filedat.c` (e.g. `file_sauce_from_path(file_t*, const char* path)`) and call it from `upload.cpp`, `ftpsrvr.cpp`, and `js_filebase.cpp`, so the three upload paths can't drift apart. (The existing DIZ handling is already triplicated; consolidating it at the same time would be a bonus.)
3. **Precedence:**
- The uploaded file's own SAUCE sets Author and Group.
- Its Title becomes the description only when the uploader/importer provided none.
- The DIZ's SAUCE fills in only fields still empty.
- Note: `file_sauce_hfields()` uses `smb_new_hfield_str()`, so calling it twice would *append duplicate* `SMB_AUTHOR`/`SMB_AUTHOR_ORG` fields. The second pass must skip fields that are already set.
4. **Gating.** Read the file's own SAUCE independently of `DIR_DIZ` (that option means "extract a description file from the archive", a different thing). Either always on, or controlled by a new per-directory toggle if sysop control is wanted. This ties into #739, which already suggests a per-directory option for using the SAUCE Title; one option could cover both.
5. **Sanitize.** SAUCE fields are uploader-controlled text, the same trust level as a DIZ. Run them through the same treatment as DIZ text (`prep_file_desc()`, truncation, stripping Ctrl-A/control characters).
## Optional extras
- **SAUCE date** (`CCYYMMDD`, already parsed into `sauce_charinfo.date`) is currently discarded. It could be stored if a suitable header field exists or is added.
- **Display hints** (width, iCE color, font) matter mainly at view time, and `prntfile.cpp` already re-reads SAUCE when displaying a file, so storing them is low value.
## Compatibility / release notes
Files that previously had no author/group will start showing them, and file listings that use `@FILE_AUTHOR@`/`@FILE_GROUP@` will change accordingly. This is likely welcome, but it should get a bullet in `docs/v322_new.md`.
Related: #739 (using the SAUCE Title from DIZ files).
*Authored by Claude (Claude Code), on behalf of @rswindell*
--- SBBSecho 3.38-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)