QWebEngine doesn't handle correctly relative url link - c++

I am working on an offline web browser that open content from archive files.
I use the QWebEngineView class to display the content and it works for most of the files I use.
But I have the case where there are links whose relative url contains "../" at the beginning and Qt doesn't seem to correctly interpret this type of path.
For example on the page which url is "question/8/turing-completeness-in-conlangs.html", there is a link like this and it redirects to "question/tag/grammar/1.html".
Is this behaviour normal ? Is there anywhere I can modify it ?
I already tried to fix this problem in the QWebEngineUrlSchemeHandler::requestStarted method but the url of QWebEngineUrlRequestJob *request is already wrong

Related

Google server is responding with an outdated html file

I'm learning socket programming using C++ , so as a project I thought of a software that downloads all image search results for a certain search(eg."cats"),
I'm using WinHttp and the exemple in here
and giving it :
the server name L"www.google.com"
object L"/search?q=cats&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiP9M3gtZTPAhXLKMAKHYSyDqIQ_AUICCgB&biw=1152&bih=634#q=cats&tbm=isch&tbs=isz:l "
The problem is that the HTML file in the response message contains what it seems to be an "Outdated" file That doesn't contain links to the real images, here it is (I can't give you the whole html file it's too long but here is an image
Research:
I first thought it was a user-agent problem so I added user-agent header, but it didn't work.
The Problem:
I want to get the same HTML result that I get when I search my browser for the same object
I found the problem it was the user-agent , just copied the user-agent from my browser

In Sitecore 7.2 file upload ,the path is coming as media\test\abc.pdf instead of media/test/abc.pdf

I am trying to add one file from file directory in directory.
While I am clicking on +(insert file) the and selecting a file from directory the path is formed as media\test\abc.pdf instead of media/test/abc.pdf.
Even though chrome is able to resolve the url Firefox is not.
I believe it's because you're using a physical file path that you're getting the backslash. One of the simplest things you can do is a string.Replace() expression to make every backslash a forward slash.
Not sure what your specific use case is, or how much work it would be, but if you're going to use the path on the web and your PDF is located in the MediaLibrary, it might be worth looking into using the URL property of the Sitecore.Data.Items.MediaItem object.

IWebBrowser2, OnBeforeNavigate2, about:

i have problems in handling a simple html-link with the IWebBrowser2-Interface.
Image i navigate to an url like that
scheme://host:port/path.html
The file path.html contains html/javascript code that automatically links to another html file, that is located in an url like this
scheme://host:port/target.html
The first file is loaded fine. But once the IE handles the link from path.html the value of the url, which is passed as a parameter to the OnBeforeNavigate2-Handler contains a strange value looking like this
"about:target.html"
There is indeed the name of the file, that path.html linked to, but the whole
remaining part of the url is lost.
Does anybody has an idea how this inconvenience could be resolved?
Thanks in advance.

Getting WebPage to use a specific URL to download HTML resources

I have a Qt program that downloads webpages (HTML), parses them and then generates its own HTML which is then displayed with QWebPage. Some times the HTML that I download contains IMG tags, which work fine when the src attribute contains a full URL. However, some times the IMG tag might use a relative path like:
<IMG SRC="images/foo.png" />
Since I know the URL that should be prepended to the SRC my first thought was to just tack it onto my resulting HTML when I'm parsing. However, this is proving more difficult than I anticipated and now I'm wondering if there's a better way.
If there any mechanism/property with QWebPage that I can say "use this URL for relative paths"? Or maybe someone can suggest a better way to accomplish what I want?
Thanks!
In the comments, you mentioned that you're using QWebView::setHtml(). The second, optional parameter of this method sets the URL to use for resolving relative paths. According to the documentation:
External objects such as stylesheets or images referenced in the HTML
document are located relative to baseUrl.
Setting that parameter should be all that's needed here.

Django and tinymcs: getting list of image files using external_image_list_url

I am trying to get external_image_list_url to work with tinymcs and Django. My understanding is that the user will be able to see a list of his or her images when clicking on the image icon (the one with the tree). From here an image can be selected and inserted.
Am I right that it is the icon with the tree? It's the one called "image". The one called "insertimage" doesn't work at all - the icon is not displayed. It and insertfile are the only ones that aren't displayed. I'm Ok with that unless I need it for this list functionality.
First I am trying just to get any image to appear in a list. I have done the following:
Created myexternallist.js and placed it where I keep my other JS files. I can access these other files via src = "/media/js/filename.js" because of my django settings. But is this also what I should put for:
tinyMCE.init({
external_image_list_url : "/media/js/myexternallist.js",
... })
In this file it says:
var tinyMCEImageList = new Array(["Logo 1", "/media/js/photo.jpg"],);
photo.jpg is in the same folder as myexternallist.js
I have also tried just "photo.jpg" and various other combinations. Not sure if my issue has to do with my relative paths or something else altogether. I'm not sure what an absolute path should be. Right now I'm working on localhost, but won't always be.
Solved it, argh. The issue was the comma near the end of the line "var tinyMCEImageList =..."
Now it works fine with the relative urls starting with /media
The clue was given by Firebug Console, which showed me the js error. I just happened to click there, but will be using that a lot from now on!