upgrading base-x library to 3.0.7
This commit is contained in:
parent
2fd649db14
commit
ef8943d838
6 changed files with 124 additions and 155 deletions
|
@ -4,7 +4,7 @@
|
||||||
* ADDED: Translation for Ukrainian (#533)
|
* ADDED: Translation for Ukrainian (#533)
|
||||||
* ADDED: Option to send a mail with the link, when creating a paste (#398)
|
* ADDED: Option to send a mail with the link, when creating a paste (#398)
|
||||||
* ADDED: Add support for CONFIG_PATH environment variable (#552)
|
* ADDED: Add support for CONFIG_PATH environment variable (#552)
|
||||||
* CHANGED: Upgrading libraries to: DOMpurify 2.0.7 & Showdown 1.9.1
|
* CHANGED: Upgrading libraries to: base-x 3.0.7, DOMpurify 2.0.7 & Showdown 1.9.1
|
||||||
* FIXED: HTML injection via unescaped attachment filename (#554)
|
* FIXED: HTML injection via unescaped attachment filename (#554)
|
||||||
* FIXED: Password disabling option (#527)
|
* FIXED: Password disabling option (#527)
|
||||||
* **1.3.1 (2019-09-22)**
|
* **1.3.1 (2019-09-22)**
|
||||||
|
|
|
@ -1,151 +0,0 @@
|
||||||
// base-x encoding / decoding
|
|
||||||
// based on https://github.com/cryptocoinjs/base-x 3.0.5
|
|
||||||
// modification: removed Buffer dependency and node.modules entry
|
|
||||||
// Copyright (c) 2018 base-x contributors
|
|
||||||
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
||||||
// Distributed under the MIT software license, see the accompanying
|
|
||||||
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
|
|
||||||
(function(){
|
|
||||||
'use strict';
|
|
||||||
this.baseX = function base (ALPHABET) {
|
|
||||||
if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long')
|
|
||||||
|
|
||||||
const BASE_MAP = new Uint8Array(256)
|
|
||||||
BASE_MAP.fill(255)
|
|
||||||
|
|
||||||
for (let i = 0; i < ALPHABET.length; i++) {
|
|
||||||
const x = ALPHABET.charAt(i)
|
|
||||||
const xc = x.charCodeAt(0)
|
|
||||||
|
|
||||||
if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous')
|
|
||||||
BASE_MAP[xc] = i
|
|
||||||
}
|
|
||||||
|
|
||||||
const BASE = ALPHABET.length
|
|
||||||
const LEADER = ALPHABET.charAt(0)
|
|
||||||
const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
|
|
||||||
const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
|
|
||||||
|
|
||||||
function encode (source) {
|
|
||||||
if (source.length === 0) return ''
|
|
||||||
|
|
||||||
// Skip & count leading zeroes.
|
|
||||||
let zeroes = 0
|
|
||||||
let length = 0
|
|
||||||
let pbegin = 0
|
|
||||||
const pend = source.length
|
|
||||||
|
|
||||||
while (pbegin !== pend && source[pbegin] === 0) {
|
|
||||||
pbegin++
|
|
||||||
zeroes++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate enough space in big-endian base58 representation.
|
|
||||||
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0
|
|
||||||
const b58 = new Uint8Array(size)
|
|
||||||
|
|
||||||
// Process the bytes.
|
|
||||||
while (pbegin !== pend) {
|
|
||||||
let carry = source[pbegin]
|
|
||||||
|
|
||||||
// Apply "b58 = b58 * 256 + ch".
|
|
||||||
let i = 0
|
|
||||||
for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) {
|
|
||||||
carry += (256 * b58[it]) >>> 0
|
|
||||||
b58[it] = (carry % BASE) >>> 0
|
|
||||||
carry = (carry / BASE) >>> 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if (carry !== 0) throw new Error('Non-zero carry')
|
|
||||||
length = i
|
|
||||||
pbegin++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip leading zeroes in base58 result.
|
|
||||||
let it = size - length
|
|
||||||
while (it !== size && b58[it] === 0) {
|
|
||||||
it++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Translate the result into a string.
|
|
||||||
let str = LEADER.repeat(zeroes)
|
|
||||||
for (; it < size; ++it) str += ALPHABET.charAt(b58[it])
|
|
||||||
|
|
||||||
return str
|
|
||||||
}
|
|
||||||
|
|
||||||
function decodeUnsafe (source) {
|
|
||||||
if (typeof source !== 'string') throw new TypeError('Expected String')
|
|
||||||
if (source.length === 0) return ''
|
|
||||||
|
|
||||||
let psz = 0
|
|
||||||
|
|
||||||
// Skip leading spaces.
|
|
||||||
if (source[psz] === ' ') return
|
|
||||||
|
|
||||||
// Skip and count leading '1's.
|
|
||||||
let zeroes = 0
|
|
||||||
let length = 0
|
|
||||||
while (source[psz] === LEADER) {
|
|
||||||
zeroes++
|
|
||||||
psz++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate enough space in big-endian base256 representation.
|
|
||||||
const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
|
|
||||||
const b256 = new Uint8Array(size)
|
|
||||||
|
|
||||||
// Process the characters.
|
|
||||||
while (source[psz]) {
|
|
||||||
// Decode character
|
|
||||||
let carry = BASE_MAP[source.charCodeAt(psz)]
|
|
||||||
|
|
||||||
// Invalid character
|
|
||||||
if (carry === 255) return
|
|
||||||
|
|
||||||
let i = 0
|
|
||||||
for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) {
|
|
||||||
carry += (BASE * b256[it]) >>> 0
|
|
||||||
b256[it] = (carry % 256) >>> 0
|
|
||||||
carry = (carry / 256) >>> 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if (carry !== 0) throw new Error('Non-zero carry')
|
|
||||||
length = i
|
|
||||||
psz++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip trailing spaces.
|
|
||||||
if (source[psz] === ' ') return
|
|
||||||
|
|
||||||
// Skip leading zeroes in b256.
|
|
||||||
let it = size - length
|
|
||||||
while (it !== size && b256[it] === 0) {
|
|
||||||
it++
|
|
||||||
}
|
|
||||||
|
|
||||||
var vch = [];
|
|
||||||
|
|
||||||
let j = zeroes
|
|
||||||
while (it !== size) {
|
|
||||||
vch[j++] = b256[it++]
|
|
||||||
}
|
|
||||||
|
|
||||||
return vch
|
|
||||||
}
|
|
||||||
|
|
||||||
function decode (string) {
|
|
||||||
const buffer = decodeUnsafe(string)
|
|
||||||
if (buffer) return buffer
|
|
||||||
|
|
||||||
throw new Error('Non-base' + BASE + ' character')
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
encode: encode,
|
|
||||||
decodeUnsafe: decodeUnsafe,
|
|
||||||
decode: decode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).call(this);
|
|
120
js/base-x-3.0.7.js
Normal file
120
js/base-x-3.0.7.js
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
'use strict';
|
||||||
|
// base-x encoding / decoding
|
||||||
|
// based on https://github.com/cryptocoinjs/base-x 3.0.7
|
||||||
|
// modification: removed Buffer dependency and node.modules entry
|
||||||
|
// Copyright (c) 2018 base-x contributors
|
||||||
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
(function(){
|
||||||
|
this.baseX = function base (ALPHABET) {
|
||||||
|
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
||||||
|
var BASE_MAP = new Uint8Array(256)
|
||||||
|
BASE_MAP.fill(255)
|
||||||
|
for (var i = 0; i < ALPHABET.length; i++) {
|
||||||
|
var x = ALPHABET.charAt(i)
|
||||||
|
var xc = x.charCodeAt(0)
|
||||||
|
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
||||||
|
BASE_MAP[xc] = i
|
||||||
|
}
|
||||||
|
var BASE = ALPHABET.length
|
||||||
|
var LEADER = ALPHABET.charAt(0)
|
||||||
|
var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
|
||||||
|
var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
|
||||||
|
function encode (source) {
|
||||||
|
if (source.length === 0) { return '' }
|
||||||
|
// Skip & count leading zeroes.
|
||||||
|
var zeroes = 0
|
||||||
|
var length = 0
|
||||||
|
var pbegin = 0
|
||||||
|
var pend = source.length
|
||||||
|
while (pbegin !== pend && source[pbegin] === 0) {
|
||||||
|
pbegin++
|
||||||
|
zeroes++
|
||||||
|
}
|
||||||
|
// Allocate enough space in big-endian base58 representation.
|
||||||
|
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0
|
||||||
|
var b58 = new Uint8Array(size)
|
||||||
|
// Process the bytes.
|
||||||
|
while (pbegin !== pend) {
|
||||||
|
var carry = source[pbegin]
|
||||||
|
// Apply "b58 = b58 * 256 + ch".
|
||||||
|
var i = 0
|
||||||
|
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
||||||
|
carry += (256 * b58[it1]) >>> 0
|
||||||
|
b58[it1] = (carry % BASE) >>> 0
|
||||||
|
carry = (carry / BASE) >>> 0
|
||||||
|
}
|
||||||
|
if (carry !== 0) { throw new Error('Non-zero carry') }
|
||||||
|
length = i
|
||||||
|
pbegin++
|
||||||
|
}
|
||||||
|
// Skip leading zeroes in base58 result.
|
||||||
|
var it2 = size - length
|
||||||
|
while (it2 !== size && b58[it2] === 0) {
|
||||||
|
it2++
|
||||||
|
}
|
||||||
|
// Translate the result into a string.
|
||||||
|
var str = LEADER.repeat(zeroes)
|
||||||
|
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
function decodeUnsafe (source) {
|
||||||
|
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
||||||
|
if (source.length === 0) { return '' }
|
||||||
|
var psz = 0
|
||||||
|
// Skip leading spaces.
|
||||||
|
if (source[psz] === ' ') { return }
|
||||||
|
// Skip and count leading '1's.
|
||||||
|
var zeroes = 0
|
||||||
|
var length = 0
|
||||||
|
while (source[psz] === LEADER) {
|
||||||
|
zeroes++
|
||||||
|
psz++
|
||||||
|
}
|
||||||
|
// Allocate enough space in big-endian base256 representation.
|
||||||
|
var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
|
||||||
|
var b256 = new Uint8Array(size)
|
||||||
|
// Process the characters.
|
||||||
|
while (source[psz]) {
|
||||||
|
// Decode character
|
||||||
|
var carry = BASE_MAP[source.charCodeAt(psz)]
|
||||||
|
// Invalid character
|
||||||
|
if (carry === 255) { return }
|
||||||
|
var i = 0
|
||||||
|
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
||||||
|
carry += (BASE * b256[it3]) >>> 0
|
||||||
|
b256[it3] = (carry % 256) >>> 0
|
||||||
|
carry = (carry / 256) >>> 0
|
||||||
|
}
|
||||||
|
if (carry !== 0) { throw new Error('Non-zero carry') }
|
||||||
|
length = i
|
||||||
|
psz++
|
||||||
|
}
|
||||||
|
// Skip trailing spaces.
|
||||||
|
if (source[psz] === ' ') { return }
|
||||||
|
// Skip leading zeroes in b256.
|
||||||
|
var it4 = size - length
|
||||||
|
while (it4 !== size && b256[it4] === 0) {
|
||||||
|
it4++
|
||||||
|
}
|
||||||
|
var vch = []
|
||||||
|
var j = zeroes
|
||||||
|
while (it4 !== size) {
|
||||||
|
vch[j++] = b256[it4++]
|
||||||
|
}
|
||||||
|
return vch
|
||||||
|
}
|
||||||
|
function decode (string) {
|
||||||
|
var buffer = decodeUnsafe(string)
|
||||||
|
if (buffer) { return buffer }
|
||||||
|
throw new Error('Non-base' + BASE + ' character')
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
encode: encode,
|
||||||
|
decodeUnsafe: decodeUnsafe,
|
||||||
|
decode: decode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).call(this);
|
|
@ -18,7 +18,7 @@ global.prettyPrint = window.PR.prettyPrint;
|
||||||
global.prettyPrintOne = window.PR.prettyPrintOne;
|
global.prettyPrintOne = window.PR.prettyPrintOne;
|
||||||
global.showdown = require('./showdown-1.9.1');
|
global.showdown = require('./showdown-1.9.1');
|
||||||
global.DOMPurify = require('./purify-2.0.7');
|
global.DOMPurify = require('./purify-2.0.7');
|
||||||
global.baseX = require('./base-x-3.0.5.1').baseX;
|
global.baseX = require('./base-x-3.0.7').baseX;
|
||||||
global.Legacy = require('./legacy').Legacy;
|
global.Legacy = require('./legacy').Legacy;
|
||||||
require('./bootstrap-3.3.7');
|
require('./bootstrap-3.3.7');
|
||||||
require('./privatebin');
|
require('./privatebin');
|
||||||
|
|
|
@ -55,7 +55,7 @@ if ($ZEROBINCOMPATIBILITY):
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-Yey/0yoaVmSbqMEyyff3DIu8kCPwpHvHf7tY1AuZ1lrX9NPCMg87PwzngMi+VNbe4ilCApmePeuKT869RTcyCQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-Yey/0yoaVmSbqMEyyff3DIu8kCPwpHvHf7tY1AuZ1lrX9NPCMg87PwzngMi+VNbe4ilCApmePeuKT869RTcyCQ==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/base-x-3.0.5.1.js" integrity="sha512-/zL3MWKMtl1IBF0URx3laql2jUw+rWfFFabNlILY/Qm+hUsQR/XULjUyNHkW/FkrV7A0sMQ7tsppH7sj5ht8wA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/base-x-3.0.7.js" integrity="sha512-/Bi1AJIP0TtxEB+Jh6Hk809H1G7vn4iJV80qagslf0+Hm0UjUi1s3qNrn1kZULjzUYuaf6ck0ndLGJ7MxWLmgQ==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/bootstrap-3.3.7.js" integrity="sha512-iztkobsvnjKfAtTNdHkGVjAYTrrtlC7mGp/54c40wowO7LhURYl3gVzzcEqGl/qKXQltJ2HwMrdLcNUdo+N/RQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/bootstrap-3.3.7.js" integrity="sha512-iztkobsvnjKfAtTNdHkGVjAYTrrtlC7mGp/54c40wowO7LhURYl3gVzzcEqGl/qKXQltJ2HwMrdLcNUdo+N/RQ==" crossorigin="anonymous"></script>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -34,7 +34,7 @@ if ($ZEROBINCOMPATIBILITY):
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-Yey/0yoaVmSbqMEyyff3DIu8kCPwpHvHf7tY1AuZ1lrX9NPCMg87PwzngMi+VNbe4ilCApmePeuKT869RTcyCQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-Yey/0yoaVmSbqMEyyff3DIu8kCPwpHvHf7tY1AuZ1lrX9NPCMg87PwzngMi+VNbe4ilCApmePeuKT869RTcyCQ==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/base-x-3.0.5.1.js" integrity="sha512-/zL3MWKMtl1IBF0URx3laql2jUw+rWfFFabNlILY/Qm+hUsQR/XULjUyNHkW/FkrV7A0sMQ7tsppH7sj5ht8wA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/base-x-3.0.7.js" integrity="sha512-/Bi1AJIP0TtxEB+Jh6Hk809H1G7vn4iJV80qagslf0+Hm0UjUi1s3qNrn1kZULjzUYuaf6ck0ndLGJ7MxWLmgQ==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
|
||||||
<?php
|
<?php
|
||||||
if ($SYNTAXHIGHLIGHTING):
|
if ($SYNTAXHIGHLIGHTING):
|
||||||
|
|
Loading…
Reference in a new issue