Skip to content

Commit 57a63a4

Browse files
committed
html_translation_table()-related fixes
1 parent 42aa9d0 commit 57a63a4

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

functions/strings/get_html_translation_table.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ function get_html_translation_table(table, quote_style) {
3434
// return false;
3535
}
3636

37-
// ascii decimals for better compatibility
38-
entities['38'] = '&';
39-
if (useQuoteStyle !== 'ENT_NOQUOTES') {
40-
entities['34'] = '"';
41-
}
42-
if (useQuoteStyle === 'ENT_QUOTES') {
43-
entities['39'] = ''';
44-
}
45-
entities['60'] = '<';
46-
entities['62'] = '>';
47-
4837
if (useTable === 'HTML_ENTITIES') {
4938
entities['160'] = ' ';
5039
entities['161'] = '¡';
@@ -143,7 +132,19 @@ function get_html_translation_table(table, quote_style) {
143132
entities['254'] = 'þ';
144133
entities['255'] = 'ÿ';
145134
}
146-
135+
136+
if (useQuoteStyle !== 'ENT_NOQUOTES') {
137+
entities['34'] = '"';
138+
}
139+
if (useQuoteStyle === 'ENT_QUOTES') {
140+
entities['39'] = ''';
141+
}
142+
entities['60'] = '<';
143+
entities['62'] = '>';
144+
145+
// ascii decimals for better compatibility
146+
entities['38'] = '&';
147+
147148
// ascii decimals to real symbols
148149
for (decimal in entities) {
149150
symbol = String.fromCharCode(decimal);

functions/strings/html_entity_decode.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ function html_entity_decode( string, quote_style ) {
2020
return false;
2121
}
2222

23-
// & must be the last character when decoding!
24-
delete(histogram['&']);
25-
histogram['&'] = '&';
26-
2723
for (symbol in histogram) {
2824
entity = histogram[symbol];
2925
tmp_str = tmp_str.split(entity).join(symbol);
3026
}
27+
tmp_str = tmp_str.split(''').join("'");
3128

3229
return tmp_str;
3330
}

functions/strings/htmlentities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function htmlentities (string, quote_style) {
1818
if (false === (histogram = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
1919
return false;
2020
}
21-
21+
histogram["'"] = ''';
2222
for (symbol in histogram) {
2323
entity = histogram[symbol];
2424
tmp_str = tmp_str.split(symbol).join(entity);

functions/strings/htmlspecialchars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function htmlspecialchars (string, quote_style) {
1616
return false;
1717
}
1818

19+
histogram["'"] = ''';
1920
for (symbol in histogram) {
2021
entity = histogram[symbol];
2122
tmp_str = tmp_str.split(symbol).join(entity);

functions/strings/htmlspecialchars_decode.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ function htmlspecialchars_decode(string, quote_style) {
2020
return false;
2121
}
2222

23-
// & must be the last character when decoding!
24-
delete(histogram['&']);
25-
histogram['&'] = '&';
26-
2723
for (symbol in histogram) {
2824
entity = histogram[symbol];
2925
tmp_str = tmp_str.split(entity).join(symbol);
3026
}
27+
tmp_str = tmp_str.split(''').join("'");
3128

3229
return tmp_str;
3330
}

0 commit comments

Comments
 (0)