-
Notifications
You must be signed in to change notification settings - Fork 142
Fix radio button unsafe token access bug #2790
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
Changes from all commits
59711b6
7eadcba
cd733dc
13355c3
333ef1d
c046805
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,10 +20,14 @@ module.exports = function(md, options) { | |
| if (group) { | ||
| group = group[1]; | ||
| } else { | ||
| group = crypto.createHash('md5') | ||
| .update(tokens[i-5].content) | ||
| .update(tokens[i-4].content) | ||
| .update(tokens[i].content).digest('hex').substr(2, 5); // generate a deterministic group id | ||
| var hash = crypto.createHash('md5'); | ||
| if (i >= 5 && tokens[i-5]) { | ||
| hash.update(tokens[i-5].content); | ||
| } | ||
| if (i >= 4 && tokens[i-4]) { | ||
| hash.update(tokens[i-4].content); | ||
| } | ||
| group = hash.update(tokens[i].content).digest('hex').substr(2, 5); // generate a deterministic group id | ||
| } | ||
| radioify(tokens[i], state.Token, group); | ||
| attrSet(tokens[i-2], 'class', 'radio-list-item'); | ||
|
|
@@ -86,9 +90,13 @@ function radioify(token, TokenConstructor, radioId) { | |
| function makeRadioButton(token, TokenConstructor, radioId) { | ||
| var radio = new TokenConstructor('html_inline', '', 0); | ||
| var disabledAttr = disableRadio ? ' disabled="" ' : ''; | ||
| if (token.content.indexOf('( ) ') === 0) { | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not cause a change in functionality (see comment in main thread) I think the refactoring is good (naming checked and unChecked), can keep that. Probably can consider using Though if you do might as well refactor the whole file which is legacy but that would go beyond the scope of the PR, and you culd and should probably do another PR for it. Tons of refactoring improvement possibilities:
Maybe tackle broader refactoring if you wish, in another PR
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted! Shall clean this up and work on refactoring in another PR in the future. |
||
| const isUnchecked = token.content.indexOf('( ) ') === 0; | ||
| const isChecked = token.content.indexOf('(x) ') === 0 || | ||
| token.content.indexOf('(X) ') === 0; | ||
| if (isUnchecked) { | ||
| radio.content = '<input class="radio-list-input" name="' + radioId + '"' + disabledAttr + 'type="radio">'; | ||
| } else if (token.content.indexOf('(x) ') === 0 || token.content.indexOf('(X) ') === 0) { | ||
| } else if (isChecked) { | ||
| radio.content = '<input class="radio-list-input" checked="" name="' + radioId + '"' + disabledAttr + 'type="radio">'; | ||
| } | ||
| return radio; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.