PDA

View Full Version : Charset bugs when loading scripts UpdateManager


grEvenX
04-26-2007, 04:26 AM
UpdateManager doesn't take into account the "charset" property on <script> tags.

I have set up an example showing the bug in detail: http://even.lynweb.no/extpg/utf_javascript/

Push on the first link which calls the javascript loaded from the head of the html page, and it gives you a properly encoded MessageBox.
Push on the second link, it will tell the update manager to update the content of the center region in my layout with a page that loads the same javascript, and then trigger the MessageBox from that source. As you can see, it doesn't seem to care for the "charset" property on the <script> tag.

With help from dfenwick on IRC we have pinpointed the source of the bug, it's in the Ext.Element class on line 1697 from Ext 1.0 release, I'd guess you just need to add a regex that checks for the charset property.

On a side-note, shouldn't the type property be included as well?

Animal
04-26-2007, 07:57 AM
It's nothing to do with Ext.

The HTTP response from http://even.lynweb.no/extpg/utf_javascript/utf_script_jsloaded.js does not contain a content encoding instruction in the Content-Type header. The browser decodes the byte streams off the net into characters, so if you don't give it any information, it will get the decoding wrong.

grEvenX
04-26-2007, 09:42 AM
Then it's more of a feature request, because that way is a common way to include javascript files with charset other than the default. You will also notice that if you actually add the "charset" property, the characters will render correctly.

Anyway, I've talked to Jack about it, and apparently he has allready fixed this in his local copy...

Animal
04-26-2007, 10:04 AM
Yes, it would be a new feature. The Element.update bit which extracts scripts would have to use a more comlpex regexp to extract the charset spec to add it to the script element it creates and appends to the doc head.

It appears that the charset spec makes the browser set the Accept-Charset header with no fallbacks, and then assume that if the server sends a response, it's in the charset requested.