Skip to content

Commit 7483c09

Browse files
committed
fix processing Hex HTML entities #992
1 parent 85aec29 commit 7483c09

11 files changed

+35
-14
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* fix `terminal::login()` when user already authenticated [#980](https://github.com/jcubic/jquery.terminal/issues/980)
1111
* improve mobile support
1212
* ignore empty command in Pipe extension [#984](https://github.com/jcubic/jquery.terminal/issues/984)
13+
* fix processing Hex HTML entities [#992](https://github.com/jcubic/jquery.terminal/issues/992)
1314

1415
## 2.44.1
1516
### Bugfix

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
99
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
1010
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
11-
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&26ea018b3abc2f72f4987018534fef0c)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
11+
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&e31addf398172b261ad412bde3188469)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
1212
![NPM Downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
1313
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded&n=1)](https://www.jsdelivr.com/package/npm/jquery.terminal)
1414
[![Paid Support](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)

__tests__/terminal.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,16 @@ describe('Terminal utils', function() {
882882
});
883883
});
884884
});
885+
describe('$.terminal.length', function() {
886+
it('shoud count html entitites', () => {
887+
const input = '▲▼\';
888+
expect($.terminal.length(input)).toBe(3);
889+
});
890+
it('should count emoji', () => {
891+
const input = '💩💩💩';
892+
expect($.terminal.length(input)).toBe(3);
893+
});
894+
});
885895
describe('$.terminal.is_formatting', function() {
886896
it('should detect terminal formatting', function() {
887897
var formattings = [

css/emoji.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/jquery.terminal.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011-2024 Jakub T. Jankiewicz <https://jcubic.pl/me>
1313
* Released under the MIT license
1414
*
15-
* Date: Mon, 18 Nov 2024 23:03:38 +0000
15+
* Date: Fri, 13 Dec 2024 15:03:29 +0000
1616
*/
1717
.terminal .terminal-output .format, .cmd .format,
1818
.cmd-prompt, .cmd-prompt div {

css/jquery.terminal.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/jquery.terminal.min.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.terminal-src.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -4801,8 +4801,13 @@
48014801
};
48024802
// -------------------------------------------------------------------------
48034803
function render_entities(str) {
4804-
return str.replace(/&#(x?)([0-9]+);/g, function(_, hex, code) {
4805-
code = parseInt(code, hex ? 16 : 10);
4804+
return str.replace(/&#(?:x([0-9a-f]+)|([0-9]+));/gi, function(_, hex, dec) {
4805+
var code;
4806+
if (hex) {
4807+
code = parseInt(hex, 16);
4808+
} else {
4809+
code = parseInt(dec, 10);
4810+
}
48064811
return String.fromCharCode(code);
48074812
}).replace(/(&[^;]+;)/g, function(_, entity) {
48084813
return entities[entity] || entity;

js/jquery.terminal.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*
4242
* broken image by Sophia Bai from the Noun Project (CC-BY)
4343
*
44-
* Date: Mon, 09 Dec 2024 20:30:04 +0000
44+
* Date: Fri, 13 Dec 2024 15:04:35 +0000
4545
*/
4646
/* global define, Map, BigInt */
4747
/* eslint-disable */
@@ -4801,8 +4801,13 @@
48014801
};
48024802
// -------------------------------------------------------------------------
48034803
function render_entities(str) {
4804-
return str.replace(/&#(x?)([0-9]+);/g, function(_, hex, code) {
4805-
code = parseInt(code, hex ? 16 : 10);
4804+
return str.replace(/&#(?:x([0-9a-f]+)|([0-9]+));/gi, function(_, hex, dec) {
4805+
var code;
4806+
if (hex) {
4807+
code = parseInt(hex, 16);
4808+
} else {
4809+
code = parseInt(dec, 10);
4810+
}
48064811
return String.fromCharCode(code);
48074812
}).replace(/(&[^;]+;)/g, function(_, entity) {
48084813
return entities[entity] || entity;
@@ -5402,7 +5407,7 @@
54025407
// -------------------------------------------------------------------------
54035408
$.terminal = {
54045409
version: 'DEV',
5405-
date: 'Mon, 09 Dec 2024 20:30:04 +0000',
5410+
date: 'Fri, 13 Dec 2024 15:04:35 +0000',
54065411
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
54075412
color_names: [
54085413
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',

js/jquery.terminal.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.terminal.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)