api: drop JSONP (#4835)

* api: drop JSONP

* docs: drop JSONP

* tests: drop JSONP

* api: remove isValidJSONPName require
pull/4846/head
John McLear 2021-02-22 09:10:02 +00:00 committed by GitHub
parent 85231cb774
commit 0f16e518ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 109 deletions

View File

@ -134,13 +134,6 @@ Authentication works via a token that is sent with each request as a post parame
All functions will also be available through a node module accessible from other node.js applications.
### JSONP
The API provides _JSONP_ support to allow requests from a server in a different domain.
Simply add `&jsonp=?` to the API call.
Example usage: https://api.jquery.com/jQuery.getJSON/
## API Methods
### Groups
@ -636,4 +629,3 @@ get stats of the etherpad instance
*Example returns*
* `{"code":0,"message":"ok","data":{"totalPads":3,"totalSessions": 2,"totalActivePads": 1}}`

View File

@ -1,85 +0,0 @@
'use strict';
const RESERVED_WORDS = [
'abstract',
'arguments',
'await',
'boolean',
'break',
'byte',
'case',
'catch',
'char',
'class',
'const',
'continue',
'debugger',
'default',
'delete',
'do',
'double',
'else',
'enum',
'eval',
'export',
'extends',
'false',
'final',
'finally',
'float',
'for',
'function',
'goto',
'if',
'implements',
'import',
'in',
'instanceof',
'int',
'interface',
'let',
'long',
'native',
'new',
'null',
'package',
'private',
'protected',
'public',
'return',
'short',
'static',
'super',
'switch',
'synchronized',
'this',
'throw',
'throws',
'transient',
'true',
'try',
'typeof',
'var',
'void',
'volatile',
'while',
'with',
'yield',
];
const regex = /^[a-zA-Z_$][0-9a-zA-Z_$]*(?:\[(?:".+"|'.+'|\d+)\])*?$/;
module.exports.check = (inputStr) => {
let isValid = true;
inputStr.split('.').forEach((part) => {
if (!regex.test(part)) {
isValid = false;
}
if (RESERVED_WORDS.indexOf(part) !== -1) {
isValid = false;
}
});
return isValid;
};

View File

@ -22,7 +22,6 @@ const createHTTPError = require('http-errors');
const apiHandler = require('../../handler/APIHandler');
const settings = require('../../utils/Settings');
const isValidJSONPName = require('./isValidJSONPName');
const log4js = require('log4js');
const logger = log4js.getLogger('API');
@ -686,12 +685,6 @@ exports.expressCreateServer = (hookName, args, cb) => {
}
}
// support jsonp response format
if (req.query.jsonp && isValidJSONPName.check(req.query.jsonp)) {
res.header('Content-Type', 'application/javascript');
response = `${req.query.jsonp}(${JSON.stringify(response)})`;
}
// send response
return res.send(response);
});

View File

@ -56,13 +56,4 @@ describe(__filename, function () {
});
});
it('supports jsonp calls', async function () {
this.timeout(150);
await agent.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
.expect(200)
.expect('Content-Type', /javascript/)
.expect((res) => {
if (!res.text.match('jsonp_1')) throw new Error('no jsonp call seen');
});
});
});