react-html-parser unexpected error - parsing

I am passing html string from my backend to react component where I am using react-html-parser to convert my html string into react component. but getting error.
ERROR in ./~/entities/maps/entities.json
Module parse failed: /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/entities.json Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:9)
at Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock. (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
# ./~/react-html-parser/~/htmlparser2/lib/Tokenizer.js 4:16-54
ERROR in ./~/entities/maps/legacy.json
Module parse failed: /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/legacy.json Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:9)
at Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock. (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
# ./~/react-html-parser/~/htmlparser2/lib/Tokenizer.js 5:16-52
ERROR in ./~/entities/maps/xml.json
Module parse failed: /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/xml.json Unexpected token (1:6)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:6)
at Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock. (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
# ./~/react-html-parser/~/htmlparser2/lib/Tokenizer.js 6:16-49
ERROR in ./~/entities/maps/decode.json
Module parse failed: /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/entities/maps/decode.json Unexpected token (1:4)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:4)
at Parser.pp$4.raise (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock. (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /Users/PrashantKumarKatariya/teabox_web/teabox_django/static/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
# ./~/entities/lib/decode_codepoint.js 1:16-46

Try adding a Json loader. had the same error and this worked for me. https://github.com/webpack-contrib/json-loader

Related

Zapier - Got a non-object result, expected an object from create ([{"http_result":"1"}])

I am getting an error when using my own App via CLI in a create on zapier.
I have looked at the logs and can see:
== Log
Unhandled error: CheckError: Invalid API Response:
Got a non-object result, expected an object from create ([{"http_result":"1"}])
What happened:
Executing creates.results.operation.perform with bundle
Invalid API Response:
Got a non-object result, expected an object from create ([{"http_result":"1"}])
CheckError: Invalid API Response:
Got a non-object result, expected an object from create ([{"http_result":"1"}])
at checkOutput (/var/task/node_modules/zapier-platform-core/src/app-middlewares/after/checks.js:42:15)
at Object. (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37)
at bound (domain.js:421:15)
at Object.runBound (domain.js:432:12)
at Object.tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromiseCtx (/var/task/node_modules/bluebird/js/release/promise.js:641:10)
at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:97:12)
at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:464:21)
at process.topLevelDomainCallback (domain.js:152:15)
at process.callbackTrampoline (internal/async_hooks.js:128:24)
I can't work out what Zapier wants as a response from a create function. I have a similar looking result set when I do a search function... but create must need something different... HELP :)

Error: no importer for key when importing "pem" key

The app follows the instruction on node-jose 2.0.0 for import .pem key. Here is the documentation:
To import and existing Key from a PEM or DER:
// input is either a:
// * String serialization of a JSON JWK/(base64-encoded) PEM/(binary-encoded) DER
// * Buffer of a JSON JWK/(base64-encoded) PEM/(binary-encoded) DER
// form is either a:
// * "json" for a JSON stringified JWK
// * "private" for a DER encoded 'raw' private key
// * "pkcs8" for a DER encoded (unencrypted!) PKCS8 private key
// * "public" for a DER encoded SPKI public key (alternate to 'spki')
// * "spki" for a DER encoded SPKI public key
// * "pkix" for a DER encoded PKIX X.509 certificate
// * "x509" for a DER encoded PKIX X.509 certificate
// * "pem" for a PEM encoded of PKCS8 / SPKI / PKIX //<<=="pem"
keystore.add(input, form).
then(function(result) {
// {result} is a jose.JWK.Key
});
The key was generated already with .pem form and its content is stored in nodejs config file as following in variable process.env.josePrivateKey:
-----BEGIN PRIVATE KEY-----
NC4CAQAwBQYcK2VwBCIEIIWUb0/MoKaBxQkmmPlHIGyPfDQb/U3D6jQ+gMUGtvpa
-----END PRIVATE KEY-----
Here is the code to add the pem key to keystore:
const jose = require('node-jose');
let keystore = jose.JWK.createKeyStore();
let privkey = await keystore.add(process.env.josePrivateKey, "pem"); //<<==this code throws error
However there is an error:
(node:11572) UnhandledPromiseRejectionWarning: Error: no importer for key
at JWKStore.value (C:\d\code\js\xyz\node_modules\node-jose\lib\jwk\keystore.js:305:21)
at initKeystore (C:\d\code\js\xyz\startup\accessstorageinfo.js:9:34) //<<==code as above
at Object.<anonymous> (C:\d\code\js\xyz\startup\accessstorageinfo.js:14:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\d\code\js\xyz\server.js:13:1)
What is missing here for key importing?
(as of March 2021) node-jose does not support the following keys: Ed25519, Ed448, X25519, or X448. It also does not support the secp256k1 EC curve. For any of those it will return the error you're encountering. As a result it does not support the JWS Algorithms EdDSA or ES256K.
On the other hand https://github.com/panva/jose supports all of the above in Node.js runtime.

ms-graph to outlook: getting error "invalid filter clause"

I have a simple enough API request:
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=isRead eq false?$select=subject,body
But the returned JSON says "Invalid filter clause"
I've tried URL encoding (i.e. adding %20 for spaces): same result
Apparently there is a typo here and that's the reason why this error occurs:
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=isRead eq false?$select=subject,body
^
query options expects '&' instead of '?' as a delimiter
Here is a valid OData URL:
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=isRead eq false&$select=subject,body
\_______________________________/\___________________________/ \__________________________________________/
| | |
service root URL resource path query options

Unable to bypass SSL Certificate Error with HTTParty in Ruby on Rails

I'm getting an SSL Certificate error when I try to access a web server using HTTParty. This is the error I got originally.
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B:
certificate verify failed
I tried to correct his by updating default options. The code is below.
class Coursera
include HTTParty
base_uri 'https://api.coursera.org/api/catalog.v1/courses'
default_params fields: "smallIcon,shortDescription", q: "search"
format :json
default_options.update(verify: false)
def self.for term
get("", query: { query: term})["elements"]
end
end
However, this resulted in another error, which is confounding me.
syntax error, unexpected tIDENTIFIER, expecting keyword_end
default_options.update(verify: false)
Can someone explain why this error is occurring and how I can bypass the SSL in order to obtain the results of the query?
You're getting syntax error, unexpected tIDENTIFIER, expecting keyword_end default_options.update(verify: false)
because of this line
HTTParty.get(get("", query: { query: term})["elements"])
There is a missing bracket at the end. Actually, you don't need to call get on HTTParty. Replace
HTTParty.get(get("", query: { query: term})["elements"])
with
get("",query: { query: term})["elements"])
Compare your file with https://github.com/jhu-ep-coursera/fullstack-course1-module3/blob/master/app/models/coursera.rb
Back to the SSl error now.
From https://gist.github.com/mislav/5026283
The reason why you might get certificate errors in Ruby 2.0 when talking > HTTPS is because there isn't a default certificate bundle that OpenSSL
(which was used when building Ruby) trusts.
Instead of disabling SSL, you can get around the error by installing the certificate.
The gist also contains information on how to install the certificate bundle manually.
Hope this helps!

Erlang error received unexpected tcp data on #Port

I retrieve a URL with the following code:
geturl(Url)->
{ok, RequestId}=httpc:request(get,{Url,[{"User-Agent", "Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.8.131 Version/11.10"}]}, [],[{sync, false}]),
M = receive
{http, {RequestId, {_HttpOk, _ResponseHeaders, _Body}}} -> ok
after 20000 ->
not_ok
end.
io:format("httprequest to ~p: ~p~n",[UrlHTTP,M]).
Sometimes I see the following error output:
httprequest to "http://www.afbudsrejser.dk": ok
=ERROR REPORT==== 30-Apr-2014::16:53:49 ===
Received unexpected tcp data on #Port<0.4432>
Data: <<"\" type=\"text/javascript\"></script>\r\n\t</body>\r\n</html>\r\n\n">>
MFA: undefined
Request: undefined
Session: {session,{{"www.afbudsrejser.dk",80},<0.4392.0>},
false,http,#Port<0.4432>,ip_comm,1,pipeline,true}
Status: pipeline
StatusLine: undefined
Profile: httpc_manager
Erlang error received unexpected tcp data on #Port
What is the cause of this error message?
The HTTP server you are connecting to is misbehaving. It declares a Content-Length header that is shorter than the response it actually sends.
This means the last few bytes the server sends (which include the string type="text/javascript"></script>) are not expected by httpc, since they violate the HTTP spec. httpc prints the warning message you're seeing when when it receives unexpected bytes that are not part of a valid HTTP response.
If you cannot fix the server, you can simply ignore this warning. You can also take a look at the relaxed httpc option, which may or may not work around this issue.

Resources