Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid TypeError when mapper is undefined #2167

Merged
merged 2 commits into from
Jan 10, 2020
Merged

Avoid TypeError when mapper is undefined #2167

merged 2 commits into from
Jan 10, 2020

Conversation

harigopal
Copy link
Contributor

A ternary operation in the prism-custom-class.js file needs to be wrapped with parentheses for it to be evaluated properly. In it's current form, it's throwing a TypeError.

let a = "foo";
let b = undefined;
let c = "default";
a + b ? b() : c;
// Uncaught TypeError: b is not a function
a + (b ? b() : c);
// "foodefault"

harigopal added a commit to pupilfirst/pupilfirst that referenced this pull request Jan 9, 2020
This was done using a yarn "rejuvenation" script:
https://gist.github.com/pftg/fa8fe4ca2bb4638fbd19324376487f42

This avoid CVE-2019-10747 in the set-value package.

I was also forced to fork the PrismJS library to fix a bug related
to improper use of the ternary operator in one of its plugins. I've
submitted a PR for that: PrismJS/prism#2167
mahesh-krishnakumar pushed a commit to pupilfirst/pupilfirst that referenced this pull request Jan 9, 2020
This was done using a yarn "rejuvenation" script:
https://gist.github.com/pftg/fa8fe4ca2bb4638fbd19324376487f42

This avoid CVE-2019-10747 in the set-value package.

I was also forced to fork the PrismJS library to fix a bug related
to improper use of the ternary operator in one of its plugins. I've
submitted a PR for that: PrismJS/prism#2167
@mAAdhaTTah mAAdhaTTah requested review from RunDevelopment and removed request for RunDevelopment January 9, 2020 12:54
@mAAdhaTTah
Copy link
Member

Thanks for the PR! Make sure you run gulp to rebuild the files & commit them.

@RunDevelopment This seems like enough of an issue that we should consider cutting another release soon. Thoughts?

Copy link
Member

@RunDevelopment RunDevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM;

But please run our build process npm ci && npx gulp.

@RunDevelopment
Copy link
Member

@mAAdhaTTah I agree. I'll get the changelog ready.

Maybe we could set up a tsconfig.json, so TSC can catch these null/undefined errors, so it won't happen again. After all, it's the second time this happened to me (#2106).

@RunDevelopment RunDevelopment merged commit 543f04d into PrismJS:master Jan 10, 2020
@harigopal harigopal deleted the patch-1 branch January 10, 2020 18:39
@harigopal harigopal restored the patch-1 branch January 10, 2020 18:43
@harigopal harigopal deleted the patch-1 branch February 26, 2020 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants