Skip to content

Handle leading zeros in quote html entity #4623

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

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Handle leading zeros in quote html entity
  • Loading branch information
gwwar committed Jan 8, 2020
commit 7dc9c4c0f5f111a7a06c97e8fb2e964f426f5f58
6 changes: 6 additions & 0 deletions test/unescape.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ describe('unescape', function() {
assert.strictEqual(unescape(escape(unescaped)), unescaped);
});

it('should handle leading zeros in html entities', function() {
assert.strictEqual(unescape('''), "'");
assert.strictEqual(unescape('''), "'");
assert.strictEqual(unescape('''), "'");
});

lodashStable.each(['`', '/'], function(entity) {
it('should not unescape the "' + entity + '" entity', function() {
assert.strictEqual(unescape(entity), entity);
Expand Down
4 changes: 2 additions & 2 deletions unescape.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const htmlUnescapes = {
}

/** Used to match HTML entities and HTML characters. */
const reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g
const reEscapedHtml = /&(?:amp|lt|gt|quot|#(0+)?39);/g
const reHasEscapedHtml = RegExp(reEscapedHtml.source)

/**
Expand All @@ -31,7 +31,7 @@ const reHasEscapedHtml = RegExp(reEscapedHtml.source)
*/
function unescape(string) {
return (string && reHasEscapedHtml.test(string))
? string.replace(reEscapedHtml, (entity) => htmlUnescapes[entity])
? string.replace(reEscapedHtml, (entity) => (htmlUnescapes[entity] || "'") )
: (string || '')
}

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy