Lift - Page displays as XML in Firefox rather than HTML - scala

I'm trying to get a simple Lift example running and I'm having a strange issue. I am using the Sonatype sample list project here. I modified the HTML slightly, but it wasn't working originally either. The issue I'm having is that when I run the local jetty server and try to access http://localhost:8080 it displays as XML in Firefox 3.6.10 rather than HTML. Note, it displays fine in IE8 but the Content-Type in IE8 is "text/html". I assume Firefox doesn't like the Content-Type "application/xhtml+xml" for some reason. The message in Firefox says:
This XML file does not appear to have
any style information associated with
it. The document tree is shown below.
Below are the response headers from Firebug:
Expires Thu, 16 Sep 2010 03:55:04 UTC
Content-Length 558
Cache-Control no-cache; private; no-store
Content-Type application/xhtml+xml; charset=utf-8
Pragma no-cache
Date Thu, 16 Sep 2010 03:55:04 UTC
X-Lift-Version 2.0-scala280-SNAPSHOT
Server Jetty(6.1.22)
..and the actual response:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Lift Test</title>
</head>
<body>
<h2>Welcome to your project!</h2>
<p>
<span>Welcome to toto01 at Wed Sep 15 20:55:04 PDT 2010</span>
</p>
<script type="text/javascript" src="/ajax_request/liftAjax.js"></script>
<script type="text/javascript">
// <![CDATA[
var lift_page = "F586508075515C1K";
// ]]>
</script>
</body>
</html>
Any ideas as to what is going wrong? How would I change the Content-Type in Lift for Firefox if that is the issue?

Alright, it looks like the problem is related to the element not having an xmlns attribute. After changing the XHTML to below it worked fine with the content type as "application/xhtml+xml":
<html xmlns="http://www.w3.org/1999/xhtml">

The problem should be in the use of both application/xhtml+xml content type and XHTML transitional dtd.
https://developer.mozilla.org/en/Mozilla_Web_Developer_FAQ

Related

Multipart email working everywhere besides on Hotmail

I have a multipart/alternative email that works perfectly on Gmail, Yahoo, and any others I've tried... besides Hotmail (and anything Microsoft I presume.)
The email just appears as raw text on Hotmail.
No matter the amount of times I slam my head against the wall and shout swearwords towards Microsoft which has become a daily activity, I cannot figure out why it doesn't work. Can you?
Here is the email if you want to try it yourself:
Headers:
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_18243133_1346573420.1408991447668"
Body:
------=_Part_18243133_1346573420.1408991447668
Content-Type: text/plain; charset=UTF-8
Hello world.
------=_Part_18243133_1346573420.1408991447668
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<p style="margin-top:50px;font-size:9px;">Hello world</p>
</body></html>
------=_Part_18243133_1346573420.1408991447668--
Here is the full code if you want to test it on your server, either use phpmail or wp_mail() that I'm using.
Update: Here is a source of received message to hotmail.
Probably it is copy-paste to pastbin bug, but your eml contains a space in delimiter line. See here:
--====f230673f9d7c359a81ffebccb88e5d61==
Content-Type: multipart=...<CR><LN>
<SPACE><CR><LN>
^^^^^^^
--====1fdbf23c3658d752511a8dbe74788e30==
If it is not a copy-paste bug than hotmail just can not recognize end of mime entity header.
What you have looks look to be compliant with RFC2046, so it should work with all MUA's (including Hotmail). But having said that, the way this message is structured is somewhat unusual, and it could be that Hotmail just isn't capable of handing such a message properly, even though it is within spec as far as RFC is concerned.
The more common way of structuring a message containing both a plain text body and an HTML body is to specify multipart/mixed in the headers, then create a multipart/alternative section which encompasses both the plain text body part and the HTML body part, using 'subboundaries' (for lack of a better term) to separate the two body parts. See below:
Message Headers
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="====f230673f9d7c359a81ffebccb88e5d61=="
Message Body
--====f230673f9d7c359a81ffebccb88e5d61==
Content-Type: multipart/alternative;
boundary="====1fdbf23c3658d752511a8dbe74788e30=="
--====1fdbf23c3658d752511a8dbe74788e30==
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hello world.
--====1fdbf23c3658d752511a8dbe74788e30==
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<p style="margin-top:50px;font-size:9px;">Hello world</p>
</body></html>
--====1fdbf23c3658d752511a8dbe74788e30==--
--====f230673f9d7c359a81ffebccb88e5d61==--

OneNote body is not sent when using non-multipart REST

I'm having some issues when I try to create a note using OneNote REST API.
This happens in my application and also when I try to use for testing purpose the apigee tool: https://apigee.com/onenote/embed/console/onenote
After some tests, i've tested the example available on OneNote documentation:
http://msdn.microsoft.com/en-us/library/office/dn575438(v=office.15).aspx#sectionSection3
On apigee, I have the following parameters:
Method: POST
Header: Content-Type: text/html and the corresponding authorization token.
Request Body:
<!DOCTYPE html>
<html>
<head>
<title>One Simple Note</title>
<meta name="created" content="2013-06-11T12:45:00.000-8:00"/>
</head>
<body>
<p>This is a simple non-multi-part HTML page.</p>
</body>
</html>
The note is sent successfully and I receive 201.
When I check my OneNote page, the note is created, but the body of the note is empty.
What am I doing wrong?
Turns out we had a bug in our system that caused messages under 16kb to be ignored. We just fixed it, so you shouldn't have any problems now!

Posting form to an iframe under strict XHTML (firefox)

For debug purposes, I run my page under strict XHTML while I develop it. But, right now, I realised, that such code will not work:
<!-- With header("Content-Type: application/xhtml+xml; charset=\"utf-8\"") -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!--blah blah blah-->
</head>
<body>
<form method="post" target="my_frame">
<button>Send the form!</button>
</form>
<iframe name="my_frame" src="about:blank"></iframe>
</body>
</html>
Try it here. And also try it with text/html content-type. I can, of course, disable the strict mode for the site, but here on SO my question is, how to get it to work a XHTML. (this means, how to make the 1. link work properly).
Fun fact: While testing the example, I noticed that <button> tag does not work in IE properly. Any ideas what's wrong? (that's side question of course)
For XHTML, use id rather than name as the attribute for the target on the iframe. For HTML/XHTML compatibility, use both a name and an id and make sure their values are the same.
However, take note that target is not a valid attribute on a form. So it won't validate, and its working is not guaranteed.
The IE one should have been another question, but IE needs type="submit" for buttons, even if that type is supposed to be the default.

what is the trick Facebook uses to inject its icon onto a linked page?

when A posts a link on Facebook, and then B clicks that link in Chrome (not in Firefox, and haven't tested others), B sees the Facebook white "f" on blue background icon (favicon.ico) shown on the tab of the linked page. sometimes, presumably when the page has its own favicon, refreshing that tab will replace the icon with the correct one; but most often the Facebook favicon remains. at first I believed Facebook was using frames in some tricky way, but using View Source, that appears not to be the case. how would one program an href or redirect in such a way as to preload one's own favicon onto a linked page as Facebook does?
here's what I've tried without success, my icon gets replaced with nothing (and only shows in both the tab and navbar in Firefox, only in the tab in Chromium, but that's beside the point):
http://unixshell.jcomeau.com/tmp/linktest/index.html
jcomeau#unixshell:~/www/www/tmp/linktest$ cat index.html
<html>
<head>
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
homesteadingsurvivalism.myshopify.com
</body>
</html>
jcomeau#unixshell:~/www/www/tmp/linktest$ cat redirect.html
<html>
<head>
<link rel="shortcut icon" href="favicon.ico" />
<script language="javascript" type="text/javascript">
var newpage = window.location.search.substring(5);
window.setTimeout('window.location = newpage; ', 3000);
</script>
</head>
<body>
<p>Redirecting to selected site, please wait...</p>
</body>
after Yan's comment I also tried with no success redirect.cgi:
jcomeau#unixshell:~/www/www/tmp/linktest$ cat redirect.cgi; QUERY_STRING=url=http://this.is.a.test/ ./redirect.cgi
#!/bin/bash
echo -ne "Content-type: text/html\r\n"
echo -ne "Location: ${QUERY_STRING:4}\r\n"
echo -ne "\r\n"
cat <<-EOF
<html>
<head>
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
Redirecting to ${QUERY_STRING:4}
</body>
</html>
EOF
Content-type: text/html
Location: http://this.is.a.test/
<html>
<head>
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
Redirecting to http://this.is.a.test/
</body>
</html>
When I do a GET request to http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBwCjI4mWPFI&h=yAQG6-ic8AQF_aOjn3QCJxdul6VnDN1Ho_ltT2gX90NF-vQ, I get the following response (I added some line breaks in the HTML for readability):
HTTP/1.1 200
Content-Length: 349
Cache-Control: private, no-cache, no-store, must-revalidate
Expires: Sat, 01 Jan 2000 00:00:00 GMT
P3P: CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"
Pragma: no-cache
Refresh: 1;URL=http://www.youtube.com/watch?v=BwCjI4mWPFI
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Set-Cookie: ***removed***
Content-Type: text/html; charset=utf-8
X-FB-Debug: ***removed***
Date: Fri, 27 Apr 2012 00:49:25 GMT
Connection: close
<html>
<head></head>
<body>
<script type="text/javascript">
document.location.replace("http:\/\/www.youtube.com\/watch?v=BwCjI4mWPFI");
</script>
<script type="text/javascript">
setTimeout("(new Image()).src=\"\\\/laudit.php?r=JS&u=http\\u00253A\\u00252F\\u00252Fwww.youtube.com\\u00252Fwatch\\u00253Fv\\u00253DBwCjI4mWPFI\";",5000);
</script>
</body>
</html>
A short trial learns that the Refresh header is enough to let this work. This is a simple implementation in PHP:
<?php
header("Refresh: 1;URL=http://www.a-website-without-favicon.com/");
?>
But, as stated earlier: this only works if the website you're referring to doesn't have a favicon.
Although I am not entirely sure how Facebook is doing it, you may try using a proxy PHP script and AJAX content load as suggested here.
/* proxy.php */
<?php echo file_get_contents($_GET['url']);?>
<html><body><div id="contentArea"></div></body></html>
$("#contentArea").load('proxy.php?url=http://example.com');
First, you'll load your own blank page with your preferred favicon.ico. Then using AJAX, you'll load the preferred content keeping the old favicon.ico.

FacebookSDK Cross Domain Receiver Problem

Hi can somebody help me. I can't get rid of this error message in Chrome 9.0 beta, Chrome 8.0 or Firefox 3.6.13:
"Unsafe JavaScript attempt to access frame with URL 'http://apps.facebook.com/myapp/' from frame with URL 'http://myapp.dyndns-office.com/'. Domains, protocols and ports must match."
I'm using the FacebookSDK version 4.1.1 CSMvcFacebookApp in the Samples folder.
I have this script in my Site.Master page located in Views/Shared:
<script language="javascript" type="text/javascript">
$(document).ready(function () {
FB_RequireFeatures(['CanvasUtil'], function () {
FB.XdComm.Server.init("<%= ResolveUrl("~/xd_receiver.htm") %>");
FB.CanvasClient.startTimerToSizeToContent();
});
});
</script>
I have xd_receiver.htm in my root directory, and presumed that the above javascript code was all I needed to do verify my domain with facebook.
Is my presumption correct or has things changed?
I even tried moving the FB code out of the JQuery ready function like so:
<script language="javascript" type="text/javascript">
FB_RequireFeatures(['CanvasUtil'], function () {
FB.XdComm.Server.init("<%= ResolveUrl("~/xd_receiver.htm") %>");
FB.CanvasClient.startTimerToSizeToContent();
});
</script>
But this doesn't work either ...
Can anybody shed some light as to what I'm doing wrong or how I get xd file to work using the SDK/MVC IFrame solution...
FB.CanvasClient.startTimerToSizeToContent() is firing because I don't have the scroll bars appear in my application, so that proves that FB_RequireFeatures function is working. But as to whether FB.XdComm.Server.init is doing it's part I'm just not sure as to how I go about testing this ???
The content of my xd_receiver.html file in my root directory is:
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>cross domain receiver page</title>
</head>
<body>
<!--
As described in: http://wiki.developers.facebook.com/index.php/Cross-domain_communication_channel
-->
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
</body>
</html>-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script>
</body>
</html>
XdCommReceiver.js exists as I just copied the pasted the url into the browser. Are my paths correct or have facebook up and change the url's etc ... ?
I understand that my main concern here is that Safari won't run my app at all if I don't get this cross domain stuff sorted out now.
Any help here would be much appreciated :-\
Thanks
Rob
<< ADDITIONAL COMMENT >>
Is there a built in mechanism in the latest version of the FacebookSDK v 4.1.1 to make this cross domain stuff just work? Did the developers of the SDK think about this issue? Or have I just brought up a future feature ... :-\
Here's the code you need to have in your cross-domain scripting channel file:
<html><body><script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script></body></html>
Here's the code to initialize the FB Javascript SDK. Put this at the very end of your HTML files, substituting in the appropriate values and URLs.
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script><script type="text/javascript">FB.init({appId: '1234567890', status: true, cookie: true, xfbml: true,channelUrl: 'http://example.com/xss_channel.htm'});</script>
Optionally, put this in your web.config where the XSS channel file is located. This lets browsers cache the file indefinitely as recommended by Facebook.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="xss_channel.htm">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Expires" value="Tue, 01 Jan 2030 16:00:00 GMT" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
</configuration>
And finally, if you're using XFBML, place this namespace definition in your <html> to make XFBML work in IE:
xmlns:fb="http://www.facebook.com/2008/fbml"
You are using the old Facebook Connect Javascript. The Facebook C# SDK is not compatible with the old Javascript SDK. You should use the new Facebook Javascript SDK (as was included in the sample). http://developers.facebook.com/docs/reference/javascript/