CFDocument isn't showing styles and images. Is HTTPS the problem? - https

I have been using CFDocument for years with no problems. Suddenly the CFDocument is not showing formatting nor static images.
I have heard of the PDF engine crapping out, but other code is generating the documents just fine. And I have rebooted the software.
Is it possible that the HTTPS vs HTTP is the problem. As the sites functioning fine are http. I have just noticed this on the https site.
I'm lost. If it is an https/http problem, what is fix?
<cfdocument
format="pdf"
filename = "inspection_pdf\#busid#_#inspid#.pdf"
overwrite = "yes"
marginBottom = ".6"
marginLeft = ".4"
marginRight = ".4"
marginTop = ".2">
<style type="text/css">#import "pdf.css";</style>
As related, this code above has been working for years with no issues.

Related

Three.js webgl video texture CORS issue on safari

In my vuejs nuxt static site hosted on netlify, I'm trying to use a mp4 video hosted on Vimeo Pro as a video texture in three.js with the following (simplified version)
// create video dom element
let video_ele = document.createElement('video')
video_ele.className = 'video_texture'
video_ele.setAttribute('playsinline', true)
video_ele.muted = true
video_ele.loop = true
video_ele.autoplay = true
video_ele.crossOrigin = 'anonymous'
video_ele.src = "https://vimeo-video-url-here.....mp4"
document.body.appendChild(video_ele)
// create video texture from video
let video_texture = new THREE.VideoTexture(video_ele)
video_texture.minFilter = THREE.LinearFilter
video_texture.magFilter = THREE.LinearFilter
video_texture.format = THREE.RGBFormat
// map video texture to material
material = new THREE.MeshStandardMaterial({
color: 0xa8a8a8,
map: video_texture
})
Everything else works fine on chrome, firefox and also chrome mobile browser.
but in Safari 13 on mac os and ios 13, i get this error thrown in the console
THREE.WebGLState:
SecurityError: The operation is insecure.
I tried replacing the vimeo video with urls of other videos hosted elsewhere and i get same error in safari only.
I'm pretty sure its a CORS issue because when i replace the vimeo or external url with a static video hosted within same host (netlify), it works fine.
I also tried appending a timestamp to the video url just to be sure its not a cache issue, but still no luck
Wondering how can i make this work with an externally hosted video like vimeo?
Upon further testing, it seems to me that the issue was caused by the 302 redirect to their CDN that happens when you use a vimeo file url.
As #gman pointed out, there's a similar issue on Soundclound and i found that the solution provided there worked for my case too.
How to get Safari 12 to process audio from soundcloud?
I solved it by making an async fetch request to get the CDN url and then passing it to the video.src. Works in safari mac and ios (13) now now!
async function getMediaURLForTrack(texture_to_update, passed_url) {
await fetch(passed_url, {
method: 'HEAD'
})
.then((response) => {
texture_to_update.src = response.url
});
}

Prevent external files in src of iframe from being cached (with CloudFlare)

I am trying to make a playground like plunker. I just noticed a very odd behavior on production (with active mode in Cloudflare), whereas it works well in localhost.
By iframe, the playground previews index_internal.html which may contain links to other files (eg, .html, .js, .css). iframe is able to interpret external links such as <script src="script.js"></script>.
So each time a user modifies their file (eg, script.js) on the editor, my program saves the new file into a temporary folder on the server, then refresh the iframe by iframe.src = iframe.src, it works well on localhost.
However, I realized that, in production, the browser always keeps loading the initial script.js, even though users modify it in the editor and a new version is written in the folder in the server. For example, what I see in Dev Tools ==> Network is always the initial version of script.js, whereas I can check the new version of script.js saved in the server by less on the left hand.
Does anyone know why it is like this? And how to fix it?
Edit 1:
I tried the following, which did not work with script.js:
var iframe = document.getElementById('myiframe');
iframe.contentWindow.location.reload(true);
iframe.contentDocument.location.reload(true);
iframe.contentWindow.location.href = iframe.contentWindow.location.href
iframe.contentWindow.src = iframe.contentWindow.src
iframe.contentWindow.location.replace(iframe.contentWindow.location.href)
I tried to add a version, it worked with index_internal.html, but did not reload script.js:
var newSrc = iframe.src.split('?')[0]
iframe.src = newSrc + "?uid=" + Math.floor((Math.random() * 100000) + 1);
If I turn Cloudflare to development mode, script.js is reloaded, but I do want to keep Cloudflare in active mode.
I found it.
We can create a custom rule for caching in CloudFlare:
https://support.cloudflare.com/hc/en-us/articles/200168306-Is-there-a-tutorial-for-Page-Rules-#cache
For example, I could set Bypass as Cache Level for the folder www.mysite.com/tmp/*.

Webkit under Windows with PyQt doesn't get remote resources via xhr

I would like to write a Qt application which uses Webkit as its gui to get data from a server and display it. I got it working unter Linux and OS X without problems but under windows the XMLHttpRequest always returns status 0 and I don't know why. Here is the pyqt code I use:
import sys, os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.page().settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True)
path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'index.html'))
url = "file://localhost/" + path
web.load(QUrl(url))
web.show()
sys.exit(app.exec_())
and here is html HTML/JS I use to test it:
<!DOCTYPE html>
<title>TEST</title>
<h1>TEST</h1>
<div id="test"></div>
<script type="text/javascript">
function t(text) { document.getElementById("test").innerHTML = text }
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if(this.status != 0)
t(this.responseText)
else
t("Status is 0")
}
xhr.open("GET", "https://jeena.net/")
xhr.send()
</script>
On Linux it opens a new Window with a WebKit view in it, loads html local index.html file into it and renders it which shows the TEST headline. After that it runs the XMLHttpRequest code to get a websites content and set it with innerHTML into the prepared div.
On windows it loads and shows the title but then when it runs the xhr code the status is always just 0 and it never changes, no matter what I do.
As far as I understand LocalContentCanAccessRemoteUrls should make it possible for the xhr to get that content from the remote website even on windows, any idea why this is not working? I am using Qt version 4.9.6 on my windows machine and python v2.7.
I think there are two simple attempts to solve this problem.
My first thinking is that it can be due to cross domain request.
Seems that there is no easy way to disable cross domain protection in QWebkit.
I got the information from this stackoverflow question:
QtWebkit Same-Origin-policy
As stated in the accepted answer:
"By default, Qt doesn't expose method to disable / whitelist the same origin policy. Extended the same (qwebsecurityorigin.cpp) and able to get it working."
But since you've got everything working on linux and mac, the above may not be the cause.
Another possibility is you don't have openssl enabled with your Qt on windows. Since I noticed you have requested to a https page, which should require openssl. You can change the page to a http one to quick test this possibility.

QWebview, HTTP proxy, html5 video does not work

I'm using QWebView to show chat log.
webView = new QWebView(this);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
webView->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
webView->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
webView->settings()->setMaximumPagesInCache(0);
webView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
If the proxy for QWebView is not set the HTML code like this works fine.
<iframe width=\"100%\" height=\"315\" frameborder=\"0\" allowfullscreen src=\"http://www.youtube.com/embed/" + rxYouTube.cap(11) + "\" ></iframe>
But when I do something like this
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName("_ip_");
proxy.setPort(_port_);
proxy.setUser("_login_");
proxy.setPassword("_passsword_");
QNetworkProxy::setApplicationProxy(proxy);
YouTube tells me that my browser does not supports HTML5.
How I can solve this problem?
PS Platform: Qt 4.8, Windows, VC
I haven't tested going through a proxy yet, although my LAN uses a transparent auto-proxy so at least that much works, but I have worked out how to get general HTML5 Video support in a QWebView on Windows. I've written a blog post about that you can read here: http://blog.enthought.com/open-source/fun-with-qtwebkit-html5-video/ It involves building Qt + qt-mobility, and also a bug fix in qt-mobility.

Problem with WebKit rendering google.com (and a few other sites)

I'm a noob to Cocoa programming, so please excuse the possible stupidity of this question.
I'm trying to build a web browser using Cocoa/MacRuby but am running into this strange rendering problem - a lot of sites render just fine, but all Google sites and a bunch of other sites (such as the CouchDB website) render with very small fonts.
I tried to mimic Firefox's HTTP request and set headers like so:
def initialize_request(url)
url_request = NSMutableURLRequest.requestWithURL(NSURL.URLWithString(url))
url_request.setValue("ISO-8859-1,utf-8;q=0.7,*;q=0.7", forHTTPHeaderField:"Accept-Charset")
url_request.setValue("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", forHTTPHeaderField:"Accept")
url_request.setValue("en-us,en;q=0.5", forHTTPHeaderField:"Accept-Language")
url_request.setValue("gzip,deflate", forHTTPHeaderField:"Accept-Encoding")
url_request.setValue("keep-alive", forHTTPHeaderField:"Connection")
url_request.setValue("300", forHTTPHeaderField:"Keep-Alive")
headers = url_request.allHTTPHeaderFields
NSLog("All headers: #{headers.inspect}")
url_request
end
Full source file is here
Any pointers will be helpful, thanks in advance!
Check the font size in your app's WebPreferences and the text-size multiplier on the WebView.

Resources