primefaces fileupload preview not working if extension is in uppercase - regex

I am trying to use primefaces advanced fileupload, however I have noticed that when the extension is in uppercase the preview does not work. Below is the upload code.
<p:fileUpload fileUploadListener="${myController.handleFileUpload}"
mode="advanced" id="fileupload"
sizeLimit="2000000" uploadLabel="Add"
dragDropSupport="false" previewWidth="190"
label="Browse" style="width: 600px;height: 200px"
required="true" update="fileDescId"
allowTypes="/(\.|\/)(gif|jpe?g|png|GIF|JPG|JPEG|PNG)$/i"/>
Searching on google has not yielded much, I found that adding /i at the end of allowTypes makes the regex case insensitive but still the preview does not show. If I click upload it upload successfully even if the preview did not show, but I need the preview because a description of the image is required.

I figured out your problem. The problem in the file \META-INF\resources\primefaces\fileupload\fileupload.js. Preview images are only available for png, jpg and gif files and for this there is a check:
//preview
if($this.isCanvasSupported() && window.File && window.FileReader && $this.IMAGE_TYPES.test(file.name))
and pattern:
IMAGE_TYPES: /(\.|\/)(gif|jpe?g|png)$/
As you can see in this place lacks the flag for case insensitive validation. So i manually add this flag
IMAGE_TYPES: /(\.|\/)(gif|jpe?g|png)$/i
and preview started working as it should. I checked several times, cleaned and put the flag, everything works.
So I sent the corresponding patch.

Related

WebKitGtk doesn't load local files

I've tried loading a local html file using webkit_web_view_load_uri() with a file:// URL. However, the webview would display a blank page. To circumvent this, I tried using webkit_web_view_load_html() and it worked correctly.
Now that I'm trying to load some images in the html using the <img> tag, the images aren't loaded (It displays a blank page).
I'm puzzled because I tried before (~ 2 months ago) a similar method and it worked.
Note: I copied the contents of the generated HTML into a file and loaded it with Firefox and it worked as it should (The images are visible), but with another WebKitGtk application I had lying around the images didn't load.
Note: I'm using C++ as the main programming language (I'd prefer having C++ types in the solutions only if possible)
Note: I have set webkit_settings_set_allow_file_access_from_file_urls() and webkit_settings_set_allow_universal_access_from_file_urls() to TRUE
Ok, I've managed to solve this. The solution had NOTHING to do with webkitgtk, which is strange. It seems that the application was trying to download the page instead of loading it. This traces to a faulty MIME type database.
Tl;Dr:
Execute this:
rm ~/.local/share/mime/packages/user-extension-html.xml
update-mime-database ~/.local/share/mime
and use webkit_web_view_load_uri() instead of webkit_web_view_load_html() with a file:// URI
I had the same problem in C. You have to explicitly set file:// as base_uri when you call webkit_web_view_load_html().
See also answer here

Opencart Remove \65279” from HTML

Inside my home.tpl, I deleted everything. But when I go to /index.php?route=common/home, it shows like this at the top:
I also tried to open home.tpl using Notepad++ and encoded it as "UTF-8 without BOM". For another page this is working fine.

wkhtmltopdf always using default sans-serif font

I'm using a Django wrapper with wkhtmltopdf however I'm having the problem that regardless of the fonts I use in my CSS it always just shows a default sans-serif font. It works locally and also works on the server when I just generate the HTML without converting it to the PDF.
This is how it shows on the server in the PDF and this is how it shows locally in the PDF. The font is a custom font base64 encoded, however it doesn't matter what font I use as none make a difference.
Is it something to do with the server setup?
Anyone have any ideas?
Thanks in advance.
What's the css you're applying to the text? wkhtmltopdf has some quirks, and apparently doesn't like fallbacks (link). I was observing something similar and finally got a serif font (closest I could get to Times New Roman w/o downloading) by doing
font-family: "serif";
wkhtmltopdf only includes fonts if it finds them in the local system in /usr/share/fonts
If you use fonts like font-family: 'Liberation Sans'; ,wkhtmltopdf will correctly include them in the PDF and render them as it should.
If someone is still looking for a solution (in the current version of wkHTMLtoPDF). The solutions above didn´t solve my problem.
For me the correct solution was to add an svg-font for each font (font-type). wkHTMLtoPDF takes at least the svg. In my case, it always took the fallback font (Arial). I just converted each font and added it to my font.scss.
I hope this helps.

django - ckeditor bug renders text/string in raw html format

am using django ckeditor. Any text/content entered into its editor renders raw html output on the webpage.
for ex: this is rendered output of ckeditor field (RichTextField) on a webpage;
<p><span style="color:rgb(0, 0, 0)">this is a test file ’s forces durin</span><span style="color:rgb(0, 0, 0)">galla’s good test is one that fails Thereafter, never to fail in real environment. </span></p>
I have been looking for a solution for a long time now but unable to find one :( There are some questions which are similar but none of those have been able to help. It will be helpful if any changes suggested are provided with the exact location where it needs to be changed. Needless to say I am a newbie.
Thanks
You need to mark the relevant variable that contains the html snippet in your template as safe
Obviously you should be sure, that the text comes from trusted users and is safe, because with the safe filter you are disabling a security feature (autoescaping) that Django applies per default.
If your ckeditor is part of a comment form and your mark the entered text as safe, anybody with access to the form could inject Javascipt and other (potentially nasty) stuff in your page.
The whole story is explained pretty well in the official docs: https://docs.djangoproject.com/en/dev/topics/templates/#automatic-html-escaping

wrong result from cfmodule with firefox

In coldfusion 8, I used bellow code to view "UserDesc"field data from database table that is working on well IE and chrome but not on Firefox. On firefox it does not display on fckeditor,but shows on textarea. please suggest any change in code.
<cfmodule
template="fckeditor/fckeditor.cfm"
basePath="../views/fckeditor/"
instanceName="Question"
value='#UrlDecode(UserDesc)#'
width="530"
height="260">
There are a few newer ways to use the ckeditor in Coldfusion. You can just use the following (this may be cf9+ only, i'm not sure):
<cftextarea name="Question" id="Question"
richtext="yes"
value="#UrlDecode(UserDesc)#">
</cftextarea>
Or you could just use the javascript one as demo'd here (this should work for any version of coldfusion): http://ckeditor.com/demo You would just have to put your value in between the opening and closing text area tags.