Skip to content
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

Fix code scanning alert #2: DOM text reinterpreted as HTML #1273

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
18 changes: 15 additions & 3 deletions assets/js/admin-pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

const { document } = window;

/**
* Escape special characters in URL components.
*
* @param {string} str The string to escape.
* @return {string} The escaped string.
*/
const escapeURLComponent = (str) => {

Check failure on line 15 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L15

[prettier/prettier] Replace `str` with `·str·`
return encodeURIComponent(str).replace(/[!'()*]/g, (c) => {

Check failure on line 16 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L16

[prettier/prettier] Replace `····return·encodeURIComponent(str).replace(/[!'()*]/g,·(c` with `↹return·encodeURIComponent(·str·).replace(·/[!'()*]/g,·(·c·`
return '%' + c.charCodeAt(0).toString(16);

Check failure on line 17 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L17

[prettier/prettier] Replace `········return·'%'·+·c.charCodeAt(0).toString(16` with `↹↹return·'%'·+·c.charCodeAt(·0·).toString(·16·`
});

Check failure on line 18 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L18

[prettier/prettier] Replace `····}` with `↹}·`
};

const chooseConnection = document.getElementById( 'pull_connections' );
const choosePostType = document.getElementById( 'pull_post_type' );
const choosePostTypeBtn = document.getElementById( 'pull_post_type_submit' );
Expand Down Expand Up @@ -82,12 +94,12 @@
* @return {string} Distribution URL.
*/
const getURL = () => {
const postType =
choosePostType.options[ choosePostType.selectedIndex ].value;
escapeURLComponent(choosePostType.options[ choosePostType.selectedIndex ].value);

Check failure on line 98 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L97-L98

[prettier/prettier] Replace `⏎↹↹escapeURLComponent(choosePostType.options[·choosePostType.selectedIndex·].value` with `·escapeURLComponent(⏎↹↹choosePostType.options[·choosePostType.selectedIndex·].value⏎↹`
const baseURL =
chooseConnection.options[ chooseConnection.selectedIndex ].getAttribute(
escapeURLComponent(chooseConnection.options[ chooseConnection.selectedIndex ].getAttribute(

Check failure on line 100 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L99-L100

[prettier/prettier] Replace `⏎↹↹escapeURLComponent(` with `·escapeURLComponent(⏎↹↹`
'data-pull-url'
);
));

Check failure on line 102 in assets/js/admin-pull.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

assets/js/admin-pull.js#L102

[prettier/prettier] Insert `⏎↹`
let status = 'new';

if ( -1 < ` ${ form.className } `.indexOf( ' status-skipped ' ) ) {
Expand Down
Loading