Character preferences / records html decoding (#17796)

Character preferences / records are now decoded correctly for the
computer UI and character preference.

Known issues, that already existed before this PR: Security incident
reports cannot be imported (nothing appears), charges and details of an
incident do not show up on the PDA application


![image](https://github.com/Aurorastation/Aurora.3/assets/65877598/86817f80-9026-49d7-92c7-57ebbffdf60c)
This commit is contained in:
Fluffy
2024-04-15 10:43:52 +02:00
committed by GitHub
parent b6f650366b
commit 417be39b6a
4 changed files with 64 additions and 9 deletions
+18 -4
View File
@@ -32,7 +32,14 @@
copied.vars[variable] = src.vars[variable]
return copied
/datum/record/proc/Listify(var/deep = 1, var/list/excluded = list(), var/list/to_update) // Mostly to support old things or to use with serialization
#define CONDITIONAL_HTML_DECODE(VAR)\
if(decode_html){\
if(istext(##VAR)){\
##VAR = html_decode(##VAR);\
}\
}
/datum/record/proc/Listify(var/deep = 1, var/list/excluded = list(), var/list/to_update, decode_html = FALSE) // Mostly to support old things or to use with serialization
var/list/record
if(!to_update)
. = record = list()
@@ -48,30 +55,37 @@
if(deep && (istype(src.vars[variable], /datum/record)))
if(to_update)
var/datum/record/R = src.vars[variable]
var/listified = R.Listify(to_update = to_update[variable])
var/listified = R.Listify(to_update = to_update[variable], decode_html = decode_html)
if(listified)
record[variable] = listified
CONDITIONAL_HTML_DECODE(record[variable])
. = record
else
var/datum/record/R = src.vars[variable]
record[variable] = R.Listify()
record[variable] = R.Listify(decode_html = decode_html)
//no escape
else if(deep && islist(src.vars[variable]) && is_list_containing_type(src.vars[variable], /datum/record))
record[variable] = list()
for(var/subr in src.vars[variable])
var/datum/record/r = subr
record[variable] += list(r.Listify())
record[variable] += list(r.Listify(decode_html = decode_html))
var/llen = 0
if((variable in to_update) && islist(to_update[variable]))
var/list/L = to_update[variable]
llen = L.len
if(llen != LAZYLEN(record[variable]))
. = record
CONDITIONAL_HTML_DECODE(.)
else if(islist(src.vars[variable]) || istext(src.vars[variable]) || isnum(src.vars[variable]))
if(to_update && record[variable] != src.vars[variable])
record[variable] = src.vars[variable]
CONDITIONAL_HTML_DECODE(record[variable])
. = record
else if(!to_update)
record[variable] = src.vars[variable]
CONDITIONAL_HTML_DECODE(record[variable])
#undef CONDITIONAL_HTML_DECODE
/datum/record/proc/Printify(var/list/excluded = list()) // Mostly to support old things or to use with serialization
@@ -124,7 +124,7 @@
"<a href='?src=\ref[src];flavor_text=open'>Set Flavor Text</a><br/>",
"<a href='?src=\ref[src];flavour_text_robot=open'>Set Robot Flavor Text</a><br/>",
"<br>",
"Signature: <font face='[pref.signfont ? pref.signfont : "Verdana"]'>[pref.signature]</font><br/>",
"Signature: <font face='[pref.signfont ? pref.signfont : "Verdana"]'>[html_decode(pref.signature)]</font><br/>",
"<a href='?src=\ref[src];edit_signature=text'>Edit Text</a> | ",
"<a href='?src=\ref[src];edit_signature=font'>Edit Font</a> | ",
"<a href='?src=\ref[src];edit_signature=help'>Help</a> | ",
@@ -164,7 +164,7 @@
else if (href_list["edit_signature"])
switch (href_list["edit_signature"])
if ("text")
var/new_sign = tgui_input_text(usr, "Please input the new character signature.", "New Signature", html2pencode(pref.signature))
var/new_sign = tgui_input_text(usr, "Please input the new character signature.", "New Signature", html2pencode(html_decode(pref.signature)), encode = FALSE)
if (!new_sign)
to_chat(usr, SPAN_NOTICE("Cancelled."))
if (pref.signature)
@@ -137,14 +137,14 @@
"sex" = R.sex,
"age" = R.age,
"fingerprint" = R.fingerprint,
"has_notes" = R.notes,
"has_notes" = html_decode(R.notes),
"physical_status" = R.physical_status,
"mental_status" = R.mental_status,
"species" = R.species,
"citizenship" = R.citizenship,
"religion" = R.religion,
"employer" = R.employer,
"notes" = R.notes,
"notes" = html_decode(R.notes),
"blood" = R.medical ? R.medical.blood_type : null,
"dna" = R.medical ? R.medical.blood_dna : null,
"ccia_notes" = R.ccia_record,
@@ -171,7 +171,7 @@
excluded += "security"
if(!(records_type & RECORD_MEDICAL))
excluded += "medical"
var/returned = active.Listify(1, excluded, data["active"])
var/returned = active.Listify(1, excluded, data["active"], decode_html = TRUE)
if(returned)
data["active"] = returned
else
@@ -0,0 +1,41 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
# admin
# backend
# security
# refactor
#################################
# Your name.
author: FluffyGhost
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- bugfix: "Character preferences / records are now decoded correctly for the computer UI and character preference."