Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bonfire: Convert HTML Entities #1108

Closed
destino92 opened this issue Jun 24, 2015 · 3 comments
Closed

Bonfire: Convert HTML Entities #1108

destino92 opened this issue Jun 24, 2015 · 3 comments

Comments

@destino92
Copy link

function convert(str) {
  // :)
  return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g,'&apos');
}
convert('Dolce & Gabbana');

assert.strictEqual(convert('Dolce & Gabbana'), 'Dolce & Gabbana', 'should escape characters');
assert.strictEqual('<>', '<>', 'should escape characters');
should escape characters: expected '<>' to equal '<>'
assert.strictEqual(convert('abc'), 'abc', 'should handle strings with nothing to escape');

@BerkeleyTrue
Copy link
Contributor

@destino92 Thanks for reporting. We will be tracking this issue at #1062

@Navankur94
Copy link

function convertHTML(str) {
var temp = str.split('');

return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g,''');
}

convertHTML("Shindler's List");

@danesh4545
Copy link

Dani_anzali@yahoo.com
در تاریخ ۲۱ مهٔ ۲۰۱۶ ۲۲:۱۴، "Navankur Srivastava" notifications@github.com
نوشت:

function convertHTML(str) {
var temp = str.split('');

// Since we are only checking for a few HTML elements I used a switch
return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g,
'"').replace(/'/g,''');
}

convertHTML("Shindler's List");


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1108 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants