HTML sanitizer in javascript [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am working on a HTML parser which receives a input from user and produce HTML document in tag. Now to avoid XSS attacks I need a simple HTML sanitizing script which filter out all java-script elements and allow only HTML component.

There is not way you can properly sanitize user input on client side, because it can all be bypassed, users can simply remove event handlers, delete javascripts. the only way to properly sanitize user input is with client-side programming language.

Related

Show a summary text/image from URL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
When users add a link within their posts on my site, I want to show a summary text/image from the URL. This is commmonly done by facebook. But how is it done ?
Any JS library/ inbuilt solution that can help me ?
Send the text the user has entered to your server
Have your server side code:
Parse it for URLs
Make HTTP requests for the URLs specified
Extract a summary/images from them (using whatever algorithm you like)
Include those in the response
Use jQuery
$.get("www.google.com", function(data) { do what ever you want to do with the data });
Change the function to extract the page content.
Get function reference
http://api.jquery.com/jquery.get/
Other posts which can help
Can Javascript read the source of any web page?

Displaying code blocks and other useful markup [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am very new to web development and was wondering if there is any useful library that will allow some type of markup to be displayed created by users similar to stackoverflow. Specifically I am asking the user the post code and want them to be able to format it.
It is actually quite simple as long as you force users to type tags as well.
If you force user to type something like this to your input form:
<b>This is bold</b> and this is not.
and use the following code:
var text = $("#input-text").val();
$("#output-element").html(text);
Then tag will be formatted as html tag and you will see bold text instead of < b > in the output element. This works for all the possible tags as well.
fiddle: http://jsfiddle.net/AKykp/

What to use for generate JavaScript using JavaScript? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
If I were to write, in JavaScript, an app that generates JavaScript code (and even interprets it and runs it) what tools/frameworks/APIis could i use?
You can run constructed javascript code using eval():
> eval("print('hi')")
hi
But you should be very careful about executing code that is constructed from user supplied input, as it has access to the environment where the code is executed, for example:
> x=3
3
> eval("print(x)")
3
In this case access to the variable x doesn't particularly matter, but you can imagine that if the executed code were constructed from user input it could access sensitive data or wreak havoc with the application.

Is there a pure Javascript X/HTML validator? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to know if there's an existing Javascript library for validating HTML, preferably not one that relies on a web API.
The closest I've found to this is John Resig's HTML parser, but that seems to be more about fixing HTML and converting it to XML.
So is there something out there already? And if not, how difficult (and lengthy) would it be to adapt John Resig's parser?
No, there isn't one. However I am writing one: https://github.com/peterjwest/html_validator
You can't validate HTML with Javascript, because Javascript is loaded from within the HTML, which means the HTML is already rendered by the browser, which means all you can see with Javascript is the dom tree. The dom tree is built by the browser, but renders with and 'fixes' invalidations.
In short: What you need to validate HTML, is the HTML source. Javascript has access to the DOM, but not to the source.
edit
And immediately after posting, I'm thinking... You don't mean validating its own page =) You just want to validate a string with a javascript... So ignore this =)

Online WYSIWYG XML editor [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Is there any open source online WYSIWYG Editor for various XML documents? I think the style could be added by XSLT, but if there is an editor, wich uses some other way to assign style to an XML file, I'm intrested.
EDIT: I've checked Xopus, Jaxe, Vex, Oxygen, Bitflux already, but none of them are matches the conditions above (not opensource, not online, etc)
WebJaxe is the online equivalent of Jaxe. It's actually more than that, since it has CMS features. As with Jaxe, you can change the look of XML elements in the editor with a config file. WebJaxe can use a PHP script and an XSLT transform to generate a website with the XML.

Categories

Resources