commit
3682505e3e
BIN
iconv-2.3.4.tgz
Normal file
BIN
iconv-2.3.4.tgz
Normal file
Binary file not shown.
86
nodejs-iconv-glibc.patch
Normal file
86
nodejs-iconv-glibc.patch
Normal file
@ -0,0 +1,86 @@
|
||||
commit a690ba5b71acb62cc3949a78eea0c73caae69cd8
|
||||
Author: Tom Hughes <tom@compton.nu>
|
||||
Date: Tue Nov 24 14:13:26 2015 +0000
|
||||
|
||||
Workaround differences in glibc iconv
|
||||
|
||||
diff --git a/lib/iconv.js b/lib/iconv.js
|
||||
index 84a2d75..97b4707 100644
|
||||
--- a/lib/iconv.js
|
||||
+++ b/lib/iconv.js
|
||||
@@ -54,13 +54,15 @@ function Iconv(fromEncoding, toEncoding)
|
||||
toEncoding + ' is not supported.');
|
||||
}
|
||||
|
||||
+ var ignore = toEncoding.match(/\/\/IGNORE(\/|$)/i);
|
||||
+
|
||||
var context_ = { trailer: null };
|
||||
|
||||
this.convert = function(input, encoding) {
|
||||
if (typeof(input) === 'string') {
|
||||
input = Buffer.from(input, encoding || 'utf8');
|
||||
}
|
||||
- return convert(conv, input, null);
|
||||
+ return convert(conv, ignore, input, null);
|
||||
};
|
||||
|
||||
this.write = function(input, encoding) {
|
||||
@@ -68,7 +70,7 @@ function Iconv(fromEncoding, toEncoding)
|
||||
input = Buffer.from(input, encoding || 'utf8');
|
||||
}
|
||||
try {
|
||||
- var buf = convert(conv, input, context_);
|
||||
+ var buf = convert(conv, ignore, input, context_);
|
||||
}
|
||||
catch (e) {
|
||||
this.emit('error', e);
|
||||
@@ -97,7 +99,7 @@ function fixEncoding(encoding)
|
||||
return /^utf[^-]/i.test(encoding) ? 'utf-' + encoding.substr(3) : encoding;
|
||||
}
|
||||
|
||||
-function convert(conv, input, context) {
|
||||
+function convert(conv, ignore, input, context) {
|
||||
if (!Buffer.isBuffer(input) && input !== FLUSH) {
|
||||
throw new Error('Bad argument.'); // Not a buffer or a string.
|
||||
}
|
||||
@@ -141,7 +143,7 @@ function convert(conv, input, context) {
|
||||
input_size -= input_consumed;
|
||||
output_start += output_consumed;
|
||||
output_size -= output_consumed;
|
||||
- if (errno) {
|
||||
+ if (errno && !(errno === EILSEQ && ignore)) {
|
||||
if (errno === E2BIG) {
|
||||
output_size += output.length;
|
||||
var newbuf = Buffer.alloc(output.length * 2);
|
||||
diff --git a/test/test-basic.js b/test/test-basic.js
|
||||
index 7cee646..19e5e89 100644
|
||||
--- a/test/test-basic.js
|
||||
+++ b/test/test-basic.js
|
||||
@@ -130,22 +130,22 @@ iconv = new Iconv('utf-8', 'ascii//ignore');
|
||||
assert.equal(iconv.convert('ça va').toString(), 'a va');
|
||||
|
||||
iconv = new Iconv('utf-8', 'ascii//translit');
|
||||
-assert.equal(iconv.convert('ça va').toString(), 'ca va');
|
||||
+assert.equal(iconv.convert('ça va').toString(), '?a va');
|
||||
|
||||
iconv = new Iconv('utf-8', 'ascii//translit');
|
||||
-assert.throws(function() { iconv.convert('ça va が'); }); // untranslatable
|
||||
+assert.equal(iconv.convert('ça va が').toString(), '?a va ?');
|
||||
|
||||
iconv = new Iconv('utf-8', 'ascii//translit//ignore');
|
||||
-assert.equal(iconv.convert('ça va が').toString(), 'ca va ');
|
||||
+assert.equal(iconv.convert('ça va が').toString(), '?a va ?');
|
||||
|
||||
iconv = Iconv('utf-8', 'iso-8859-1');
|
||||
assert.equal(iconv.convert('b2s=', 'base64').toString(), 'ok');
|
||||
|
||||
var aixEncodings =
|
||||
- 'CP856 CP922 CP943 CP1046 CP1124 CP1129 CP1161 CP1162 CP1163';
|
||||
+ 'CP856 CP922 CP1046 CP1124 CP1129 CP1161 CP1162 CP1163';
|
||||
|
||||
var dosEncodings =
|
||||
- 'CP437 CP737 CP775 CP852 CP853 CP855 CP857 CP858 CP860 CP861 ' +
|
||||
+ 'CP437 CP737 CP775 CP852 CP855 CP857 CP860 CP861 ' +
|
||||
'CP863 CP864 CP865 CP869 CP1125';
|
||||
|
||||
// Check that AIX and DOS encodings are available.
|
||||
78
nodejs-iconv-safer-buffer.patch
Normal file
78
nodejs-iconv-safer-buffer.patch
Normal file
@ -0,0 +1,78 @@
|
||||
From faec05bb6e5bf9a59e912c9a3b47e9150539d8bd Mon Sep 17 00:00:00 2001
|
||||
From: Tom Hughes <tom@compton.nu>
|
||||
Date: Thu, 21 Mar 2019 10:06:30 +0000
|
||||
Subject: [PATCH 1/2] Patch out use of safer-buffer
|
||||
|
||||
---
|
||||
lib/iconv.js | 1 -
|
||||
package.json | 3 +--
|
||||
test/test-basic.js | 1 -
|
||||
test/test-big-buffer.js | 1 -
|
||||
test/test-stream.js | 1 -
|
||||
5 files changed, 1 insertion(+), 6 deletions(-)
|
||||
|
||||
diff --git a/lib/iconv.js b/lib/iconv.js
|
||||
index 829b069..84a2d75 100644
|
||||
--- a/lib/iconv.js
|
||||
+++ b/lib/iconv.js
|
||||
@@ -20,7 +20,6 @@ exports.Iconv = Iconv;
|
||||
|
||||
var stream = require('stream');
|
||||
var util = require('util');
|
||||
-var Buffer = require('safer-buffer').Buffer;
|
||||
|
||||
var bindings;
|
||||
try {
|
||||
diff --git a/package.json b/package.json
|
||||
index 00b7d88..f1a7db5 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -18,8 +18,7 @@
|
||||
"license": "ISC",
|
||||
"readmeFilename": "README.md",
|
||||
"dependencies": {
|
||||
- "nan": "^2.13.1",
|
||||
- "safer-buffer": "^2.1.2"
|
||||
+ "nan": "^2.13.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/run-tests.js"
|
||||
diff --git a/test/test-basic.js b/test/test-basic.js
|
||||
index a007c7b..7cee646 100644
|
||||
--- a/test/test-basic.js
|
||||
+++ b/test/test-basic.js
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
var assert = require('assert');
|
||||
var Iconv = require('../lib/iconv').Iconv;
|
||||
-var Buffer = require('safer-buffer').Buffer;
|
||||
|
||||
// unknown source/target encoding
|
||||
assert.throws(function() { new Iconv('utf-8', 'xxx'); });
|
||||
diff --git a/test/test-big-buffer.js b/test/test-big-buffer.js
|
||||
index f94719d..bda8f95 100644
|
||||
--- a/test/test-big-buffer.js
|
||||
+++ b/test/test-big-buffer.js
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
var Iconv = require('../lib/iconv').Iconv;
|
||||
var assert = require('assert');
|
||||
-var Buffer = require('safer-buffer').Buffer;
|
||||
|
||||
var iconv = new Iconv('UTF-8', 'UTF-16LE');
|
||||
|
||||
diff --git a/test/test-stream.js b/test/test-stream.js
|
||||
index 279ff20..3d22a77 100644
|
||||
--- a/test/test-stream.js
|
||||
+++ b/test/test-stream.js
|
||||
@@ -21,7 +21,6 @@ var assert = require('assert');
|
||||
var stream = require('stream');
|
||||
var net = require('net');
|
||||
var fs = require('fs');
|
||||
-var Buffer = require('safer-buffer').Buffer;
|
||||
var PORT = 12345;
|
||||
|
||||
assert(new Iconv('ascii', 'ascii') instanceof stream.Stream);
|
||||
--
|
||||
2.20.1
|
||||
|
||||
46
nodejs-iconv.spec
Normal file
46
nodejs-iconv.spec
Normal file
@ -0,0 +1,46 @@
|
||||
%{?nodejs_find_provides_and_requires}
|
||||
Name: nodejs-iconv
|
||||
Version: 2.3.4
|
||||
Release: 1
|
||||
Summary: Text recoding in JavaScript for fun and profit
|
||||
License: ISC
|
||||
URL: https://github.com/bnoordhuis/node-iconv
|
||||
Source0: https://registry.npmjs.org/iconv/-/iconv-%{version}.tgz
|
||||
Patch0: nodejs-iconv-safer-buffer.patch
|
||||
Patch1: nodejs-iconv-glibc.patch
|
||||
ExclusiveArch: %{nodejs_arches}
|
||||
BuildRequires: nodejs-devel node-gyp npm(nan) >= 2.2.1 npm(tap)
|
||||
%{?nodejs_default_filter}
|
||||
%description
|
||||
%{summary}.
|
||||
|
||||
%prep
|
||||
%autosetup -p 1 -n package
|
||||
%nodejs_fixdep --dev --move nan
|
||||
rm -rf deps support node_modules
|
||||
|
||||
%build
|
||||
%nodejs_symlink_deps --build
|
||||
export CXXFLAGS="%{optflags}"
|
||||
export LDFLAGS="%{?__global_ldflags} -Wl,-z,undefs"
|
||||
node-gyp rebuild -- -Dnode_iconv_use_system_libiconv=1
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}%{nodejs_sitearch}/iconv/build/Release
|
||||
cp -pr package.json lib %{buildroot}%{nodejs_sitearch}/iconv
|
||||
install -p -m755 build/Release/iconv.node %{buildroot}%{nodejs_sitearch}/iconv/build/Release
|
||||
%nodejs_symlink_deps
|
||||
|
||||
%check
|
||||
%nodejs_symlink_deps --check
|
||||
mkdir test/tmp
|
||||
%{nodejs_sitelib}/tap/bin/tap.js test/test-*.js
|
||||
|
||||
%files
|
||||
%doc README.md
|
||||
%license LICENSE
|
||||
%{nodejs_sitearch}/iconv
|
||||
|
||||
%changelog
|
||||
* Thu Aug 20 2020 wangxiao <wangxiao65@huawei.com> - 2.3.4-1
|
||||
- Package init
|
||||
5
nodejs-iconv.yaml
Normal file
5
nodejs-iconv.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
git_url: https://github.com/bnoordhuis/node-iconv
|
||||
version_control: github
|
||||
src_repo: bnoordhuis/node-iconv
|
||||
tag_prefix: "^v"
|
||||
seperator: "."
|
||||
Loading…
x
Reference in New Issue
Block a user