prebid / Prebid.js

Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.
https://docs.prebid.org
Apache License 2.0
1.33k stars 2.09k forks source link

prebid.js 0-19-0 Javascript code contains non-standard characters #994

Closed headerbidding closed 7 years ago

headerbidding commented 7 years ago

0-19-0 prebid.js breaks the javascript code and I get a "Invalid or unexpected token" error.

mkendall07 commented 7 years ago

@headerbidding I can't reproduce this issue.

Edit: sent you an email

headerbidding commented 7 years ago

Error was caused by using a text editor that dropped "text containing characters that cannot be represented in the file’s character set” from the javascript code.

mkendall07 commented 7 years ago

@headerbidding Sorry for all the hassle. Glad you figured it out finally.

headerbidding commented 7 years ago

Is it allowed for Javascript code to have non-standard characters? Up to Version 18, running the prebid.js javascript through a html text editor has not been a problem.

headerbidding commented 7 years ago

The exact character that broke the code for my javascript editor (Microsoft Expression Web) was this one: �

It is part of this sequence: w=[" \n�\f\r Â áš€á Žâ€€â€�  ","        â�Ÿã€€\

I am suspicious that the code may be corrupted... and even though it "works", I am hesitant to use it. It just doesn't look right to me. And even Microsoft Expression Web's javascript editor can't handle it....

Note: the character "�" does not display correctly here. It is the circle with arrow (male sign) ♂ symbol.

headerbidding commented 7 years ago

After further testing, I found that this issue does ALSO occur if I only choose the appnexus adapter.

Suspicious code section: RegExp.prototype.test,E),I=[" \n \f\r   ᠎    ","          \u2028","\u2029"].

You'll find it if you search for "RegExp.prototype.test"

mkendall07 commented 7 years ago

This is a complex topic, but to summarize, no a JS string can contain any UTF-16 encoded character. This is a superset of ASCII.

The reason why this is occurring in the build now is because of a change we made to include some polyfills for IE. The polyfill contains this source code: https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324 (spec: http://es5.github.io/#WhiteSpace )

The characters that seem strange, are representations of whitespace / tabs. These get converted down to UTF-8 representations with the Uglify JS plugin.

This all seems valid to me.