rapps-db icon indicating copy to clipboard operation
rapps-db copied to clipboard

[CI] Validate uploaded icons

Open learn-more opened this issue 4 months ago • 3 comments

learn-more avatar Mar 21 '24 23:03 learn-more

.ico files just start with 3 zero bytes or something like that, would be trivial to do without external tools if all one cares about is not being confused with a PNG or jpg.

I say this as someone who runs the validation inside ROS and is sensitive in python changes.

whindsaks avatar May 08 '24 11:05 whindsaks

.ico files just start with 3 zero bytes or something like that, would be trivial to do without external tools if all one cares about is not being confused with a PNG or jpg.

I say this as someone who runs the validation inside ROS and is sensitive in python changes.

Does this updated script no longer work for you?

learn-more avatar May 08 '24 11:05 learn-more

Does this updated script no longer work for you?

No, not directly no.

python -m pip install --upgrade pip
python -m pip install python-magic
python -m pip install python-magic-bin
.github\validate-rapps.py

and it then fails with a missing VC runtime error (caused by python-magic-bin).

All you need is

# Check 6 byte icon header
import struct
f = open("winfile.ico", "rb")
if struct.unpack("<H", f.read(2))[0] == 0:
	if struct.unpack("<H", f.read(2))[0] == 1:
		if struct.unpack("<H", f.read(2))[0] > 0:
			print("Smells like a .ico")
f.close()

(Pardon my bad style, I hate Python)

ROS is limited to Python v3.4.4

whindsaks avatar May 08 '24 21:05 whindsaks