forked from openmediavault/openmediavault
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue openmediavault#1750: Log viewer cuts messages with special HTML…
… characters (openmediavault#1758) The `text` datatable cell template will escape all special HTML characters. If HTML code should be rendered in a datatable column, use the `html` template. Fixes: openmediavault#1750 Signed-off-by: Volker Theile <votdev@gmx.de>
- Loading branch information
Showing
24 changed files
with
102 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ data: | |
sortable: true | ||
prop: message | ||
flexGrow: 2 | ||
cellTemplateName: text | ||
sorters: | ||
- dir: desc | ||
prop: ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
deb/openmediavault/workbench/src/app/shared/pipes/escape-html.pipe.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { EscapeHtmlPipe } from '~/app/shared/pipes/escape-html.pipe'; | ||
|
||
describe('TrustHtmlPipe', () => { | ||
const pipe: EscapeHtmlPipe = new EscapeHtmlPipe(); | ||
|
||
it('create an instance', () => { | ||
expect(pipe).toBeTruthy(); | ||
}); | ||
|
||
it('transform value (1)', () => { | ||
const value = null; | ||
expect(pipe.transform(value)).toBe(value); | ||
}); | ||
|
||
it('transform value (2)', () => { | ||
const value = 1; | ||
expect(pipe.transform(value)).toBe(value); | ||
}); | ||
|
||
it('transform value (3)', () => { | ||
const value = '<f..tp..... foo bar'; | ||
expect(pipe.transform(value)).toBe('<f..tp..... foo bar'); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
deb/openmediavault/workbench/src/app/shared/pipes/escape-html.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* This file is part of OpenMediaVault. | ||
* | ||
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3 | ||
* @author Volker Theile <volker.theile@openmediavault.org> | ||
* @copyright Copyright (c) 2009-2024 Volker Theile | ||
* | ||
* OpenMediaVault is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* OpenMediaVault is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import * as _ from 'lodash'; | ||
|
||
@Pipe({ | ||
name: 'escapeHtml' | ||
}) | ||
export class EscapeHtmlPipe implements PipeTransform { | ||
/** | ||
* Converts the characters "&", "<", ">", '"', and "'" in string to | ||
* their corresponding HTML entities. | ||
* | ||
* @param value The value to be converted. If it is not a string, | ||
* then the value will be bypassed without converting special HTML | ||
* characters to their corresponding HTML entities. | ||
* @return The converted value if it is a string, otherwise the | ||
* origin value will be bypassed. | ||
*/ | ||
transform(value: any): any { | ||
if (_.isString(value)) { | ||
return _.escape(value); | ||
} | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters