ID:2665709
 
Code:
    w_say(msg as text)
set hidden = 1

if(worldmute && !usr.IsMaster()) return
if(MUTE.len) if(usr.key in MUTE) return
if(!msg) return

if(!usr.talk)
var/u_name = "[fadename(usr,usr.name)]"
var/du_name = "[fadename(usr,usr.name,1)]"

usr.talk = 1

var/check_msg = "[SpamCheck(msg)]"

if(findtext(check_msg,"~")) check_msg = card_link(check_msg)

for(var/client/C) if(C.mob) if(!C.mob.block.Find(usr.key))
if(C.mob.vmode) spawn() C.mob << {"<a title="[usr.key]" href='byond://?src=\ref[usr];action=pm'><IMG SRC=\ref[usr.avatar] width="18" height="18"></a><b>\[[time2text(world.timeofday,"hh:mm")]\]</b> <b>[du_name]: </font></b>[NaughtyCheck(check_msg,C.mob.Config["f"])]"}
else spawn() C.mob << {"<a title="[usr.key]" href='byond://?src=\ref[usr];action=pm'><IMG SRC=\ref[usr.avatar] width="18" height="18"></a><b>\[[time2text(world.timeofday,"hh:mm")]\]</b> <b>[u_name]: </font></b>[NaughtyCheck(check_msg,C.mob.Config["f"])]"}

usr.talk = 0

return


Problem description:

I have an input skin element that has this command mapped to it. It seems to act weird with quotes though. But it doesn't seem to be the command itself that does it.

If I put text in the input on the skin, I get a few unexpected outputs...

(input) - (output)

("Test") - (Test) /Quotes removed
("Test) - (Test) /Quote removed
(Test") - (Test") /Outputs correctly
(A "Test") - (A "Test") /Outputs correctly
(A "Test" B) - (A "Test" B) /Outputs correctly
("Test" B) - ERROR / produces the following error...
Sorry, the following is not valid: B
usage: w-say "text"

however... all of those inputs, including the last one that produces the error normally, will give the correct output, quotes included, if you just push enter on the input, which gives a 'w-say "text"' input pop-up looking for a text input.

From my personal testing...

It seems to be if you push enter so you get forced to enter text via the input pop-up, it treats it as the command being typed as... w-say "(input here)" - with the extra quotes include

But if you enter the text through the input, it's like if you input it via client > command without encapsulating it. which, if you try the same inputs as above, give the same results.

So I guess ultimately the fix for this would be... is there a way, when using a skin input, to encapsulate the text, or to html encode the text, so that BYOND doesn't have a heart attack when a player uses a quote as the first character of their text and will actually parse the text through to the code properly?
You could try using the document text format:

"this is normal text, "quotes" need escaping"

{"this is document format text, "quotes" don't need escaping but other things do"}
IceFire2050 wrote:

So I guess ultimately the fix for this would be... is there a way, when using a skin input, to encapsulate the text, or to html encode the text, so that BYOND doesn't have a heart attack when a player uses a quote as the first character of their text and will actually parse the text through to the code properly?

There is an html_encode() proc for this.

http://www.byond.com/docs/ref/#/proc/html_encode

If I'm understanding correctly it looks like you want to pass the input string from the player through there, which can be done like so:

var/encoded_txt = html_encode(input_string)