MCPcopy Index your code
hub / github.com/NetHack/NetHack / sanitize_name

Function sanitize_name

src/bones.c:197–220  ·  view source on GitHub ↗

while loading bones, strip out text possibly supplied by old player that might accidentally or maliciously disrupt new player's display */

Source from the content-addressed store, hash-verified

195/* while loading bones, strip out text possibly supplied by old player
196 that might accidentally or maliciously disrupt new player's display */
197void
198sanitize_name(char *namebuf)
199{
200 int c;
201 boolean strip_8th_bit = (WINDOWPORT(tty)
202 && !iflags.wc_eight_bit_input);
203
204 /* it's tempting to skip this for single-user platforms, since
205 only the current player could have left these bones--except
206 things like "hearse" and other bones exchange schemes make
207 that assumption false */
208 while (*namebuf) {
209 c = *namebuf & 0177;
210 if (c < ' ' || c == '\177') {
211 /* non-printable or undesirable */
212 *namebuf = '.';
213 } else if (c != *namebuf) {
214 /* expected to be printable if user wants such things */
215 if (strip_8th_bit)
216 *namebuf = '_';
217 }
218 ++namebuf;
219 }
220}
221
222/* Give object to a random object-liking monster on or adjacent to x,y
223 but skipping hero's location.

Callers 6

petname_optfnFunction · 0.85
optfn_fruitFunction · 0.85
fruitaddFunction · 0.85
resetobjsFunction · 0.85
getbonesFunction · 0.85
sanitize_engravingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected