ID:1979785
 
Not a bug
BYOND Version:509.1313
Operating System:Windows 10 Pro 64-bit
Web Browser:Chrome 46.0.2490.80
Applies to:Webclient
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
I have the following code:

// DM
src << output("Honk!", "main_output");

...

// DMS

<script>
{
fn:
{
output: function(obj)
{
if (obj.hasOwnProperty("text"))
{
try
{
alert(obj.text);
}
catch (ex)
{
alert(ex.message);
}
}
}
}
}
</script>


In the webclient I receive the following alert:
Honk!<br/>


Numbered Steps to Reproduce Problem:
1. Use the above code to send a message.
2. A <br/> is appended to the string.

Expected Results:
The message is sent as-is.

Actual Results:
The message is altered.

Does the problem occur:
Every time? Or how often?
Every time.
In other games?
Unknown.
In other user accounts?
Unknown.
On other computers?
Unknown.

When does the problem NOT occur?
The problem always occurs.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Unknown - first time I'm using the webclient properly.

Workarounds:
Manually strip the BR tag from the string. This is not desirable as the current behavior may change in the future. The string should not be manipulated at all but passed on directly, and it should be up to the skin developer to decide what to do.
Lummox JR resolved issue (Not a bug)
This is correct behavior. If you want to avoid the <br/>, you need to follow your string with \... so it doesn't have a trailing line break.

Bear in mind if you want to show the text as plaintext, you'll also need to strip out any HTML formatting and convert the HTML back to text. The webclient includes convenience routines to do this.

obj.text = byond.htmlDecode(obj.text);
obj.text = obj.text.replace(/\n+$/,''); // to remove trailing line breaks
obj.text = obj.text.replace(/^\n+/,''); // to remove leading line breaks (usually not necessary)
Can this behavior be documented in the webclient manual and/or the reference for output()? I'm fairly certain I won't be the only one who runs into this particular quirk. :)
I mean, really, a way to send data to dms that doesn't do ANY messing with the data might be needed, since apparently output isn't it.

Text output gets filtered like regular chat output would. The built-in controls account for this as needed.