ROFF
text/troff
Magic Bytes
Offset: 0
2E 5C 22
ROFF is a document formatting system originally developed by Joe Ossanna for the Unix operating system and currently maintained through the GNU groff project. It serves as the primary language for typesetting manual pages and technical documentation within Unix-like environments using specific macro packages. Although largely a legacy format, it remains secure due to its plain text structure, presenting minimal risk beyond potential resource exhaustion during complex rendering tasks.
Validation Code
How to validate .roff files in Python
Python
def is_roff(file_path: str) -> bool:
"""Check if file is a valid ROFF by magic bytes."""
signature = bytes([0x2E, 0x5C, 0x22])
with open(file_path, "rb") as f:
return f.read(3) == signature
How to validate .roff files in Node.js
Node.js
function isROFF(buffer: Buffer): boolean {
const signature = Buffer.from([0x2E, 0x5C, 0x22]);
return buffer.subarray(0, 3).equals(signature);
}
Go
func IsROFF(data []byte) bool {
signature := []byte{0x2E, 0x5C, 0x22}
if len(data) < 3 {
return false
}
return bytes.Equal(data[:3], signature)
}
API Endpoint
GET
/api/v1/roff
curl https://filesignature.org/api/v1/roff