This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 20935 - code example input breaks layout
Summary: code example input breaks layout
Status: NEW
Alias: None
Product: webplatform.org
Classification: Unclassified
Component: infrastructure (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Doug Schepers
QA Contact: public-webplatform-bugs list
URL: www.meow1.com
Whiteboard:
Keywords:
: 20936 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-09 13:32 UTC by mail
Modified: 2013-05-27 02:23 UTC (History)
3 users (show)

See Also:


Attachments

Description mail 2013-02-09 13:32:53 UTC
This code example breaks the layout, though I don't know whats the reason for this:

<!doctype html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>Image preview example</title>
<script type="text/javascript">
oFReader = new FileReader(), rFilter = 'image/jpg';
 
oFReader.onload = function (oFREvent) {
  document.getElementById("uploadPreview").src = oFREvent.target.result;
};
 
function loadImageFile() {
  if (document.getElementById("uploadImage").files.length === 0) { return; }
  var oFile = document.getElementById("uploadImage").files[0];
  if (!rFilter.test(oFile.type)) { alert("You must select a valid image file!"); return; }
  oFReader.readAsDataURL(oFile);
}
</script>
</head>
 
<body onload="loadImageFile();">
  <form name="uploadForm">
    <table>
      <tbody>
        <tr>
          <td><img id="uploadPreview" style="width: 100px; height: 100px;" src="" alt="Image preview" /></td>
          <td><input id="uploadImage" type="file" name="myPhoto" onchange="loadImageFile();" /></td>
        </tr>
      </tbody>
    </table>
 
    <p><input type="submit" value="Send" /></p>
  </form>
</body>
</html>
Comment 1 Chris Mills 2013-02-09 14:03:03 UTC
It sucks, but the code example fields don't get escaped automatically, so some of the HTML is being interpreted.

For the display code, try escaping the angle brackets, for example with HTML entity references.
Comment 2 mail 2013-02-09 14:04:39 UTC
replacing all html entities helps, but this could be automated
Comment 3 Chris Mills 2013-02-09 14:05:56 UTC
Agreed.

I've got it on my feedback list for this weekend, and will raise it as a task to be done.
Comment 4 David Kirstein (Frozenice) 2013-02-09 14:27:57 UTC
*** Bug 20936 has been marked as a duplicate of this bug. ***