Firefox Extension - Need a specific div to ignore xhtml errors (mismatched tag, etc) - firefox-addon

My firefox extension loads content from a 3rd party site into an overlay panel. This content is user generated and sometimes will, for instance, have an image tag that does not close which causes a mismatched tag error to be thrown and the extension fails. Is there any way I can sandbox this content so that these kind of errors are not an issue? I was thinking maybe load the content into a blank iframed page.. but was wondering if there might be a cleaner solution.

Unfortunately, unless you're getting back XML, there is no XPCOM solution for parsing. Your best bet is what you suggested - placing the content in an iframe.
You can find some more discussion about the topic at: http://www.mozdev.org/pipermail/greasemonkey/2005-April/001255.html

Your guess about an iframe was correct, there's no better way to do it (as of Firefox 3.5): Parsing HTML From Chrome on MDC

Related

Excessive number of pages when printing a webpage

So I am trying to print a webpage with javascript:window.print();. Rest of the website works perfectly fine. There is this one page where the data is coming from 3rd party sources which might be the culprit but I am not sure at this moment. But when I try to print this page the print window shows 'Loading preview...' and total number of pages are astonishing 31000+. When it should hardly be a 3 page print.
When I turn OFF my VPN (which allow me to access those 3rd party sources and fetch and render the data on the page) the access is revoked from the 3rd party sources, making the print work fine with only 1 page.
I tried searching on the internet for this issue but no luck.
The application is built in Drupal 9 having twig as template engine. So I simply fixed html indentation and found out it was an extra </div> tag which was causing this issue. So guys always indent your code and be careful with writing lots of html in a single template. :)

CSP and browser extensions

According to Wikipedia in "Browser Add-Ons and Extensions Exemption" section:
CSP should not interfere with the operation of browser add-ons or
extensions installed by the user...
But unfortunately it is blocking external scripts, injected by my add-on.
I can always put this injected code in to the content script. But I'm wondering if there is another way to overcome this.
You should indeed put your code into a content script. If you insert a <script> tag into a page then it works exactly the same as if the web page itself inserted it. The browser has no way of knowing that this code belongs to your extension. What's worse, this code isn't safe from manipulations by the webpage - e.g. the webpage can redefine window.alert() method and your code won't be able to show messages. Extension code and content scripts on the other hand aren't affected by this, these see only the raw DOM objects without any JavaScript-induced changes.

Why does imageresizer not work for img tags and only for direct url's?

I've just added imageresizer to my MVC4 app, but for an image tag as below, it does no resizing. If I paste the url directly into my browser, it gets resized.
<img class="store-display-image" src="/Images/ToughBook.jpg?width=130">
Why is this? I suspect routing is messing imageresizer around, but I installed the routing shim as instructed. The diagnostic url, /resizer.debug.ashx, only warns me I have NoCache set.
As the same HTTP request occurs both ways (except for the Referer header, which is irrelevant here), it's impossible for your statement to be true.
One of the following must be happening:
Your 'store-display-image' css class contains client-size width/height settings that are overriding the true size of the image.
Neither image is being resized (perhaps you're running IIS6 or IIS7 Classic - see the docs for supporting that), but your browser is automatically resizing the 'address bar' version to fit inside the window.
Your page has a 'base' tag that is changing the 'src' value.
You're just making a typo somewhere.
To avoid downvotes on future questions, I suggest providing more detailed information, such as the exact URL you used in the address bar, the css for 'store-display-image', the document URL containing the img tag, your server details, and a copy of your diagnostics page.
I also suggest showing effort to simplify the circumstances, such as trying an empty HTML page and simple element with no CSS applied, and (for strange situations like this), screenshots of both situations.

Firefox question: Is it possible to create an html iframe which loads a document from my extension using the chrome://?

I was wondering if it is possible to create an iframe whithin a HTML document pointing to a XUL document whithin my firefox extension such like:
<iframe src="chrome://myextension/content/document.xul"/>
I am currently getting security errors when trying to do this. I've already tried the contentaccessible=yes flag in my chrome.manifest but it didn't work.
Is there any workaround to get this working?
Thanks.
No, web pages are generally not allowed to load chrome documents. contentaccessible=yes refers to images and scripts that are less regulated security-wise (they can also be used across domains). However, your extension has permission to load chrome documents - even into a content page. So doing something like this from your extension will work:
window.content.frames[0].location.href = "chrome://myextension/content/document.xul";
Not sure whether this will help you, depends on what you are trying to achieve.

Post/Redirect/Get in Webkit causes a full page reload

It seems that in Webkit-based browsers (Chrome and Safari) when a Post/Redirect/Get is performed on the server, the entire page (html + images + css, etc.) is redownloaded. It appears the same as if you reloaded the page.
There's been a question (and somewhat of a solution) posted in the Google Chrome Help: http://www.google.com/support/forum/p/Chrome/thread?tid=72bf3773f7e66d68&hl=en
Does anyone have a more elegant way of doing this? I'm working with ASP.NET MVC and would prefer to not write a custom Redirect result that returns Javascript or the actual page based on the UserAgent.
Should I just hope and wait that Webkit will change its behavior?
This is a bug. The only "workaround" I've seen untill now is to use a Refresh header instead of a Location header to do the redirecting. This is far from ideal.
Bug 38690 - Submitting a POST that leads to a server redirect causes all cached items to redownload
Also, this question is a duplicate of "Full page reload on Post/Redirect/Get ignoring cache control".
Try setting Cache-Control: public header.

Resources