Skip to content
Merged

Fixes #1437

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,18 @@ export class DbTableWidgetsComponent implements OnInit {
"options": [
{
"value": "UA",
"label": "🇺🇦 Ukraine"
"label": "🇺🇦 Ukraine",
"background_color": "gold"
},
{
"value": "PL",
"label": "🇵🇱 Poland"
"label": "🇵🇱 Poland",
"background_color": "#FF1212"
},
{
"value": "US",
"label": "🇺🇸 United States"
"label": "🇺🇸 United States",
"background_color": "rgba(100, 150, 255, 0.5)"
}
]
}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@

.field-view-value {
padding: 2px 6px;
border-radius: 4px;
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<span class="field-view-value">{{displayValue}}</span>
<span class="field-view-value" [style.backgroundColor]="backgroundColor">{{displayValue}}</span>

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

Potential security vulnerability: Using user-provided color values directly in inline styles without validation could allow CSS injection attacks. Consider validating the background_color value against a whitelist of safe color formats (hex, rgb, rgba, named colors) or sanitizing the input before applying it to the DOM.

Suggested change
<span class="field-view-value" [style.backgroundColor]="backgroundColor">{{displayValue}}</span>
<span class="field-view-value" [style.backgroundColor]="backgroundColor | safeColor">{{displayValue}}</span>

Copilot uses AI. Check for mistakes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BaseRecordViewFieldComponent } from '../base-record-view-field/base-rec
})
export class SelectRecordViewComponent extends BaseRecordViewFieldComponent implements OnInit {
public displayValue: string;
public backgroundColor: string;

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

Missing initialization of backgroundColor property. If setDisplayValue() is not called or the else branch (line 33-35) is taken, the backgroundColor will be undefined, which could cause issues with the template binding. Initialize it to 'transparent' at declaration: public backgroundColor: string = 'transparent';

Suggested change
public backgroundColor: string;
public backgroundColor: string = 'transparent';

Copilot uses AI. Check for mistakes.

ngOnInit(): void {
this.setDisplayValue();
Expand All @@ -28,6 +29,7 @@ export class SelectRecordViewComponent extends BaseRecordViewFieldComponent impl
(opt: { value: any, label: string }) => opt.value === this.value
);
this.displayValue = option ? option.label : this.value;
this.backgroundColor = option && option.background_color ? option.background_color : 'transparent';

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

Accessibility concern: Setting a background color without ensuring sufficient text contrast can create readability issues for users with visual impairments. Consider either: 1) validating that the provided color has sufficient contrast with the text color, 2) automatically adjusting the text color based on the background, or 3) documenting that developers must provide WCAG-compliant color combinations.

Copilot uses AI. Check for mistakes.
} else if (this.structure?.data_type_params) {
// If no widget structure but we have data_type_params, just use the value
this.displayValue = this.value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@

.field-value {
padding: 2px 6px;
border-radius: 4px;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="field-display">
<span class="field-value">{{displayValue}}</span>
<span class="field-value" [style.backgroundColor]="backgroundColor">{{displayValue}}</span>

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

Potential security vulnerability: Using user-provided color values directly in inline styles without validation could allow CSS injection attacks. Consider validating the background_color value against a whitelist of safe color formats (hex, rgb, rgba, named colors) or sanitizing the input before applying it to the DOM.

Suggested change
<span class="field-value" [style.backgroundColor]="backgroundColor">{{displayValue}}</span>
<span class="field-value" [style.backgroundColor]="safeBackgroundColor">{{displayValue}}</span>

Copilot uses AI. Check for mistakes.
<button type="button" mat-icon-button
class="field-copy-button"
matTooltip="Copy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
})
export class SelectDisplayComponent extends BaseTableDisplayFieldComponent implements OnInit {
public displayValue: string;
public backgroundColor: string;

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

Missing initialization of backgroundColor property. If setDisplayValue() is not called or the else branch (line 37-39) is taken, the backgroundColor will be undefined, which could cause issues with the template binding. Initialize it to 'transparent' at declaration: public backgroundColor: string = 'transparent';

Suggested change
public backgroundColor: string;
public backgroundColor: string = 'transparent';

Copilot uses AI. Check for mistakes.

ngOnInit(): void {
this.setDisplayValue();
Expand All @@ -32,6 +33,7 @@ export class SelectDisplayComponent extends BaseTableDisplayFieldComponent imple
(opt: { value: any, label: string }) => opt.value === this.value
);
this.displayValue = option ? option.label : this.value;
this.backgroundColor = option && option.background_color ? option.background_color : 'transparent';

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

Accessibility concern: Setting a background color without ensuring sufficient text contrast can create readability issues for users with visual impairments. Consider either: 1) validating that the provided color has sufficient contrast with the text color, 2) automatically adjusting the text color based on the background, or 3) documenting that developers must provide WCAG-compliant color combinations.

Copilot uses AI. Check for mistakes.
} else if (this.structure?.data_type_params) {
// If no widget structure but we have data_type_params, just use the value
this.displayValue = this.value;
Expand Down
Loading