HTML and JS Escaping HowTo. What is escaping ? Escaping is a way to differentiate between characters used as part of syntax of a language and data. Eg:

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introducing JavaScript
JavaScript and AJAX Jonathan Foss University of Warwick
WeB application development
Data Representation Kieran Mathieson. Outline Digital constraints Data types Integer Real Character Boolean Memory address.
XML Primer. 2 History: SGML vs. HTML vs. XML SGML (1960) XML(1996) HTML(1990) XHTML(2000)
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
1 HTML’s Transition to XHTML. 2 XHTML is the next evolution of HTML Extensible HTML eXtensible based on XML (extensible markup language) XML like HTML.
Week 09, Session 01 Other HTML Tags & HTML5 IF Website Development Presented by: RDT.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Copyright (c) 2010, Dr. Kuanchin Chen1 The Client-Server Architecture of the WWW Dr. Kuanchin Chen.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Introduction to XML. What is XML? Extensible Markup Language XML Easier-to-use subset of SGML (Standard Generalized Markup Language) XML is a.
2440: 211 Interactive Web Programming Expressions & Operators.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
Chapter 3: Data Types and Operators JavaScript - Introductory.
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
C Derived Languages C is the base upon which many build C++ conventions also influence others *SmallTalk is where most OOP comes Java and Javascript have.
CS346 Javascript -3 Module 3 JavaScript Variables.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Lecture: Web Design Assis. Prof. Freshta Hanif Ehsan Faculty of Computer Science Kabul Polytechnic University Spring Semester
Strings, output, quotes and comments
JavaScript Syntax, how to use it in a HTML document
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Web Server Design Week 2 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 1/20/10.
1 Server versus Client-Side Programming Server-SideClient-Side.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
1 JavaScript in Context. Server-Side Programming.
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
OVERVIEW AND PARSING JSON. What is JSON JavaScript Object Notation Used to format data Commonly used in Web as a vehicle to describe data being sent between.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
Introduction to Computer CC111 Week 13 More on HTML 1.
Javascript Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
Web Server Design Week 3 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 1/23/06.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
>> Introduction to JavaScript
Tutorial 10 Programming with JavaScript
JavaScript is a programming language designed for Web pages.
Scope, Objects, Strings, Numbers
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
Section 3.2c Strings and Method Signatures
Chapter 19 JavaScript.
JavaScript an introduction.
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
WEB PROGRAMMING JavaScript.
PHP Intro/Overview Bird Book pages 1-11,
PHP.
Introduction to Primitive Data types
JavaScript What is JavaScript? What can JavaScript do?
JavaScript What is JavaScript? What can JavaScript do?
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
Java Script Siddharth Srivastava.
JavaScript is a scripting language designed for Web pages by Netscape.
CHAPTER 2 BASIC JAVASCRIPT INSTRUCTIONS
Web Server Design Week 3 Old Dominion University
Web Server Design Week 3 Old Dominion University
Introduction to Primitive Data types
Presentation transcript:

HTML and JS Escaping HowTo

What is escaping ? Escaping is a way to differentiate between characters used as part of syntax of a language and data. Eg: Java: String name="My name is \""; Javascript: Var name= "My name is \""; Html :

HTML Escaping Reserved Characters in HTML HTML and XHTML processors must support the five special characters listed in the table below: CharacterEntity NumberEntity NameDescription """quotation mark ''&apos;apostrophe &&&ampersand <<<less-than >>>greater-than

Javascript Escaping in Javascript you can use single quote(') or double quote as delimiter for strings. So If you have either double quote or single quote in the value it should be escaped as follows var iAmSingleQuote='\''; var iAmDoubleQuote="\"";

HTML & JS Escaping In case we need Both javascript HTML escaping do javascript escaping first and then do HTML Escaping Original Corrected with HTML and Javascript escaping

URL Encoding Why :RFC 1738: Uniform Resource Locators (URL) specification The specification for URLs (RFC 1738, Dec. '94) limits the use of allowed characters in URLs to only a limited subset of the US-ASCII character set: "...Only alphanumerics [0-9a-zA-Z], the special characters "$-_.+!*'()," [not including the quotes - ed], and reserved characters used for their reserved purposes may be used unencoded within a URL." URL encoding of a character consists of a "%" symbol, followed by the two- digit hexadecimal representation (case-insensitive) of the ISO-Latin code point for the character.ISO-Latin Eg : Use the javascript method encodeURIComponent() to encode all parameter values in URLs and encodeURI() to encode the whole URL. escape() method in javascript is deprecated and shouldn't be used.

Recommendation: HTML Escaping Use standard tag libraries like JSTL and Spring Tags.They handle escaping by default.They have boolean attributes related to escaping which are by default true. Eg : Spring form tag JSTL out tag

Recommendation: Javascript Escaping Get values from the Dom as much as possible and avoid assigning values from server side

Reference htm