Skip to content

Commit

Permalink
UICHKIN-421: Only certain HTML tags should be rendered when displayin…
Browse files Browse the repository at this point in the history
…g staff slips
  • Loading branch information
Dmitriy-Litvinenko committed Mar 19, 2024
1 parent 69aa418 commit 8840106
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* UI tests replacement with RTL/Jest for Scan component. Refs UICHKIN-289.
* Add support for displaySummary token for Staff Slips. Refs UICHKIN-415.
* Remove DST boundary adjustment for item return time. Refs UICHKIN-420.
* Only certain HTML tags should be rendered when displaying staff slips. Refs UICHKIN-421.

## [9.0.1] (https://github.com/folio-org/ui-checkin/tree/v9.0.1) (2023-10-23)
[Full Changelog](https://github.com/folio-org/ui-checkin/compare/v9.0.0...v9.0.1)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
},
"dependencies": {
"dateformat": "^2.0.0",
"dompurify": "^3.0.9",
"final-form": "^4.19.1",
"html-to-react": "^1.3.3",
"inactivity-timer": "^1.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/components/ComponentToPrint/ComponentToPrint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import HtmlToReact, { Parser } from 'html-to-react';
import Barcode from 'react-barcode';
import * as DOMPurify from 'dompurify';

import { buildTemplate } from '../../util';

export const shouldProcessNode = node => node.name === 'barcode';
Expand Down Expand Up @@ -39,7 +41,7 @@ class ComponentToPrint extends React.Component {
const {
dataSource,
} = this.props;
const componentStr = this.template(dataSource);
const componentStr = DOMPurify.sanitize(this.template(dataSource));
const Component = this.parser.parseWithInstructions(componentStr, () => true, this.rules) || null;

return (
Expand Down
4 changes: 4 additions & 0 deletions src/components/ComponentToPrint/ComponentToPrint.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable max-classes-per-file */
import Barcode from 'react-barcode';
import * as DOMPurify from 'dompurify';

Check warning on line 3 in src/components/ComponentToPrint/ComponentToPrint.test.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

'DOMPurify' is defined but never used. Allowed unused vars must match /React/u

Check warning on line 3 in src/components/ComponentToPrint/ComponentToPrint.test.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

'DOMPurify' is defined but never used. Allowed unused vars must match /React/u

import {
render,
Expand Down Expand Up @@ -30,6 +31,9 @@ jest.mock('../../util', () => ({
buildTemplate: jest.fn(Template => (data) => (Template ? <Template {...data} /> : null)),
}));
jest.mock('react-barcode', () => jest.fn(() => null));
jest.mock('dompurify', () => ({
sanitize: jest.fn((data) => (data)),
}));

describe('ComponentToPrint', () => {
const buttonText = 'Test button string';
Expand Down

0 comments on commit 8840106

Please sign in to comment.