-
-
Notifications
You must be signed in to change notification settings - Fork 86
RG-T117 View call fix #448
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
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 |
|---|---|---|
|
|
@@ -964,22 +964,55 @@ | |
| <script type="text/javascript"> | ||
| var callId = @(Model.Call.CallId); | ||
|
|
||
| var newCallForm = $('#fb-template').formRender({ | ||
| dataType: 'json', | ||
| formData: '@Html.Raw(Model.Call.CallFormData)', | ||
| notify: { | ||
| error: function(message) { | ||
|
|
||
| }, | ||
| success: function(message) { | ||
| $('input, textarea, select', '.rendered-form').attr('readonly', true).attr('disabled', true) | ||
| }, | ||
| warning: function(message) { | ||
| var callFormData = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Call.CallFormData ?? string.Empty, new Newtonsoft.Json.JsonSerializerSettings { StringEscapeHandling = Newtonsoft.Json.StringEscapeHandling.EscapeHtml })); | ||
|
|
||
| // CallFormData is API-writable free text; older/external clients stored plain text | ||
| // (e.g. "Submitted ...") which formRender's JSON.parse can't handle. Only render the | ||
| // form for valid formBuilder data, otherwise show the raw text read-only. | ||
| var callFormFields = null; | ||
| try { | ||
| callFormFields = JSON.parse(callFormData); | ||
| } catch (e) { } | ||
|
|
||
| if (Array.isArray(callFormFields)) { | ||
| // form-render inserts label/option/description content as HTML and its sanitizer is a | ||
|
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. The var declaration of newCallForm violates Rule [37] which requires const/let for variable declarations. Since newCallForm is assigned once and never reassigned, replace var with const. Kody rule violation: Always use const and let Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| // no-op unless DOMPurify is loaded (it isn't). CallFormData is API-writable, so escape | ||
| // the HTML-rendered props and show them as plain text. | ||
| var escapeHtml = function (value) { | ||
| return typeof value === 'string' | ||
| ? value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') | ||
| : value; | ||
| }; | ||
| callFormFields.forEach(function (field) { | ||
| if (!field || typeof field !== 'object') return; | ||
| field.label = escapeHtml(field.label); | ||
| field.description = escapeHtml(field.description); | ||
| if (Array.isArray(field.values)) { | ||
| field.values.forEach(function (option) { | ||
| if (option && typeof option === 'object') option.label = escapeHtml(option.label); | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| var newCallForm = $('#fb-template').formRender({ | ||
| dataType: 'json', | ||
| formData: JSON.stringify(callFormFields), | ||
| notify: { | ||
| error: function(message) { | ||
|
|
||
| }, | ||
| success: function(message) { | ||
| $('input, textarea, select, button', '#fb-template .rendered-form').attr('readonly', true).attr('disabled', true) | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| warning: function(message) { | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| }); | ||
| }); | ||
| } else if (callFormData) { | ||
| $('#fb-template').text(callFormData); | ||
| } | ||
| </script> | ||
|
|
||
| <script src="~/js/app/common/signalr/resgrid.common.signalr.js" type="text/javascript"></script> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty catch block on line 975 swallows the JSON.parse exception silently, leaving no diagnostic trail for malformed CallFormData despite Rule [28] requiring caught exceptions be logged with context. Add a minimal console.warn with the callId inside the catch block.
Kody rule violation: Avoid empty catch blocks
Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.