How would I strip special characters from a filename in CKEditor before file/image upload? - file-upload

My users are uploading files/images with CKEditor, and some of the filenames have special characters. This breaks the page when the results are output in the display page (Get a 404 error, can't find file). When we tell the user to try removing the special characters before uploading, it works. I'm sure I could insert some RegEx code in CKEditor to strip those before upload, but where?

Related

Post html content to an activity with Google + Domains API

I'm triying to post HTML content to an activity with the new google + domains API with no success.
Activity activity = new Activity()
.setObject(new Activity.PlusObject().setContent("First line<br><b>second line</b>"))
.setAccess(acl);
Acording to the documentation with setConent you can specify "The HTML-formatted content, which is suitable for display." but when i try to post some html its get displayed as plain text.
I need to create an activity with some linebreaks and bold text. How can i achieve that?
Thanks in advance.
the content (HTML) field is only meant for output, you are not allowed to write in HTML. You should be writing in plain text (as you do in the browser), newlines are respected with normal line breaks (\n)
This field is useful to display formatted posts that contain links etc..

Disable browser cache for displayed in an iFrame PDF by means of TCPDF

I am trying for hours to solve the following caching problem.
My application has the following structure (simplified):
index.php - main page (contains various input fields, submit button and an iframe for dispaying PDF content with the help of TCPDF)
generate.php - generates PDF file based on the supplied POST parameters and stores the file to the filesystem
viewer.php - Displays the PDF document (TCPDF libraries). The iframe loads this script to show the pdf file
The workflow is pretty simple - the user chooses some options and clicks the submit button on the main page. The selected parameters are sent per AJAX by POST to the generate.php script. The script generates the PDF file and stores it to the filesystem. At the end it returns the newly created/edited filename. The filename is fetched in the AJAX callback function, which then refreshes the iframe with the new/edited filename:
viewer.php?filename=NEW_OR_EDITED_FILENAME
Everything is working, but when the file is being replaced, sometimes (NOT ALWAYS), the browser shows the old pdf file, although the new version is on the hard drive. I tried the following solutions:
Add Meta tags to disable cache to the generated HTML by index.php and viewer.php
Disabling cache for jQuery AJAX calls by: jQuery.ajaxSetup({cache: false});
Adding some random string to the the filename parameter:
viewer.php?filename=FILENAME_RANDOMSTRING
The RANDOMSTRING is then removed from the script and the filename is extracted.
None of these solutions worked for me. Tested browsers are: Chrome 25.0.1364.152 and Firefox 19.0. Can someone help me with this?
Thanks in advance
Just had the same problem but after adding a random string it works perfect:
<iframe src="file.pdf?=<?=time();?>"></iframe>
After many hours of trying, the solution I found is to really generate a new file each time (Solution 3 from the question without removing the random string at the end of the file). As a result it was necessary to update the database and to delete the old files on every change. My initial intention was to avoid these actions, but unfortunately no other solution was found

How can i format the HTML contents of mail in iphone ?

I am using MFMailComposer for mailing.I just convert the contents of URL in a string and use that string to send mail . But the problem is that HTML file contains button link image and when i mail it gives two blank icon with the HTML page.How can i remove that icons before the mail is send.
If it is not necessary to convert URL content to string. Simply pass HTML in MFMailComposer.
But even if you want to detect the TAGs in content of URL then simply parse the whole HTML of URL and check for button(input) tag. and you can check for completed button tag also. Simply ignore the statements between starting and ending point of tags and create another HTML content.

Coldfusion variable to code

I need a way to turn code stored in a variable into real code. We are passing Video embed code inputed from a form through to a page to display the video. Its so that people can 'attach' a shared video from another site to a post.
<cfoutput>
#attributes.embed#
</cfoutput>
simply outputs the code as text
This could open up a security hole depending on what people paste in here. Is it possible to ask visitors to paste in the URL of the shared video and depending on the format of the URL you output it into your own code? Using a switch statement based on the inputted URL, you could provide one output template for YouTube, another for Vimeo, etc.
EDIT
That said, HTML code should output easily unless it has been escaped. However, if you wish to output Coldfusion code, you will need to write the code to a file and then cfinclude the file into your output document. (not recommended, but possible)
EDIT 2
When you 'view source' on the page, do you see angle brackets around the pasted code or angle brackets replaced with &rt and &gt? if you see the &gt then something along the way has encoded the HTML, and you'll need to decode it again with a function around the variable.
<cfoutput>
#decodeFunctionHere(attributes.embed)#
</cfoutput>
Coldfusion 8 has a decode function named urlDecode if your text is encoded to a url format, using % signs. For &gt &rt another function will need to be used to do the substitution. Should be one on cflib.org or it's easy to write. Let me know.
Found the answer if anyone else is looking:
http://speeves.erikin.com/2009/06/coldfusion-replace-html-ized-characters.html

HTML encoded links and anchors

I have a use case where I am setting the page focus to a particular element (having an anchor before it). When a user is not signed in, there is a redirect to the login page and after signing in, the user is redirected to the page in question, with the URL encoded.
I see that a URL of the form link#target works as expected (focusing on the element) while the url encoded link link%23target doesn't. Is this expected behavior?
Edit: If this is the expected behavior, is there a work around to focus on the target? As in, a way around url encode?
Edit adding more info:
Assuming that there is a code
page1.html
... html before the anchor ...
<a name="test">Some code</a>
... html after the anchor ...
I am accessing the page as page1.html%23test. This doesn't work the same way as page1.html#test. Is there a jQuery method to implement this? Would location.hash contain test even after it has been url encoded? I have no control on changing the url encoding.
Edit:
As I knew which named anchor I wanted to go to after page is redirected, I did a
window.location.hash = namedAnchor
to solve the issue. This JS line is output only if a customer is successfully signed in. Solved my issue, though not the generic answer I was looking for. I was looking for a way to avoid escaping of # in url encode.
Yes. Encoding the # as %23 effectively says "I just mean a plain old "#" character, not a URL fragment". The same is true of other reserved characters: escaping them stops them from having special meaning in the URL.
In your case you do want to encode the URL when passing it to your login page as a parameter, but your login page should decode the URL before performing the redirect.
You can both parse this string with PHP or other script language, or with JavaScript using the encodeURIComponent. I wrote an article for that, you can check on http://www.stoimen.com/blog/2009/05/25/javascript-encode-cyrillic-symbols-with-encodeuricomponent/
Hope that can help you. However despite the default behavior you must check with either method.