-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes xenos seeing raw html on paper #4654
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,41 @@ var/global/list/limb_types_by_name = list( | |
index++ | ||
return output_message | ||
|
||
// proc that parses an html input string and scrambles the non-html string contents | ||
/proc/stars_decode_html(message) | ||
if(!length(message)) | ||
return | ||
|
||
// todo: sanitize string more to remove unnencessary <>. | ||
// list of parsed strings that have been scrambled, used to then reinsert the scrambled strings in to the message | ||
var/list/replaced_scrambled_strings = list() | ||
|
||
// boolean value to know if the current indexed element needs to be added to the scrambled message. | ||
var/parsing_message = FALSE | ||
|
||
// the current string value that needs to be scrambled. | ||
var/current_string_to_scramble = "" | ||
|
||
for(var/character_index in 1 to length(message)) | ||
if(message[character_index] == ">") | ||
parsing_message = TRUE | ||
continue | ||
if(message[character_index] == "<") | ||
parsing_message = FALSE | ||
if(!length(current_string_to_scramble)) | ||
continue | ||
var/scrambled_string = stars(current_string_to_scramble) | ||
replaced_scrambled_strings[current_string_to_scramble] += scrambled_string | ||
current_string_to_scramble = null | ||
continue | ||
if(parsing_message) | ||
current_string_to_scramble += message[character_index] | ||
|
||
for(var/unscrambled_message_key in replaced_scrambled_strings) | ||
message = replacetext(message, unscrambled_message_key, replaced_scrambled_strings[unscrambled_message_key]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Carefully-crafted user input would make this replace text inside of HTML tags. This should be reworked to be a bit more similar to how Your current code also means that duplicates of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll make it iterative. |
||
|
||
return message | ||
|
||
/proc/slur(phrase) | ||
phrase = html_decode(phrase) | ||
var/leng=length(phrase) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to check for quotation marks inside of HTML tags. Consider a tag such as
<tag property=">Injection()" />
. So when you are inside an HTML tag and run into a quotation mark (either single'
or double"
), then you advance until you find the matching quotation mark. Perhaps you could add a couple booleans for this, e.g.need_single_quote
andneed_double_quote
.Maybe it would be a bit overkill but it's probably good to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright.