YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub

YUI 2.x

Ticket #2528670 (checkedin defect)

Reporter


bzbugs
Opened: 12/2/09
Last modified: 12/10/09
Status: checkedin
Type: defect
Resolution: fixed

Owner


Adam Moore
Target Release:
Priority: P3 (normal)
Summary: [bz 3215571] Regression in 2.8: Get no longer uses UTF-8 as default encoding
Description:

In YUI 2.7 and earlier, the Get utility used UTF-8 as the default encoding for scripts and CSS files. In YUI 2.8, it no
longer does. This is likely related to the deprecation of the charset property, but it's a problematic change in
behavior as well, since applications may have depended on this default behavior.

The test case in Steps to Verify shows the change: With YUI 2.7, the string "æå­åã" shows up correctly
on the page no matter whether the call to Get.script specifies a charset or not. With YUI 2.8, the string is reduced to
mojibake when the call does not specify a charset.

Type: defect Observed in Version: 2.8.0
Component: Get Utility Severity: S3 (normal)
Assigned To: Adam Moore Target Release:
Location: Priority: P3 (normal)
Tags: Relates To:
Browsers: N/A
URL:
Test Information:

Use a server that does not set the charset parameter in the HTTP Content-Type header for JavaScript files.

Use the following two one-line scripts:

mojibake-default.js:
var mojibake_default = "æå­åã";

mojibake-unicode.js:
var mojibake_unicode = "æå­åã";

and the following HTML page loading them:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Get Mojibake</title>
</head>
<body>

<h2>Loaded using YUI Get with default charset</h2>

<p id="default"></p>

<h2>Loaded using YUI Get with charset=utf-8</h2>

<p id="unicode"></p>

<!-- YUI 2 scripts -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo/yahoo-debug.js" ></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/get/get-debug.js" ></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/dom/dom-debug.js"></script>

<script type="text/javascript">

YAHOO.util.Get.script("mojibake-default.js", {
onSuccess: function() {
YAHOO.util.Dom.get('default').innerHTML = mojibake_default;
}
});

YAHOO.util.Get.script("mojibake-unicode.js", {
attributes: { charset: "utf-8" },
onSuccess: function() {
YAHOO.util.Dom.get('unicode').innerHTML = mojibake_unicode;
}
});

</script>

</body>
</html>

To test with YUI 2.8, replace "2.7.0" in the script src attributes with "2.8.0r4".

When loading the page, the string "æå­åã" should show up twice.

Change History

Adam Moore

YUI Developer

Posted: 12/10/09
  • resolution changed to fixed
  • status changed from new to checkedin

nodes get charset='utf-8' by default. [fixes #2528670].
View Commit: