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

CFP-68 - Sanitized SVG content to fix Cross-Site Scripting issues #119

Merged
merged 25 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3a8184f
chore:sanitized SVG content to fix xss issues
yssambare12 Apr 21, 2024
3165d8e
chore:added few more esc_html for variation
yssambare12 Apr 21, 2024
8d594d9
chore:added few more esc_html for variation
yssambare12 Apr 21, 2024
e584de4
revert few changes
yssambare12 Apr 21, 2024
31634e8
revert few changes
yssambare12 Apr 21, 2024
bd54975
run phpcbf
yssambare12 Apr 21, 2024
7e55415
run phpcbf
yssambare12 Apr 21, 2024
eb2365b
fix phpcs
yssambare12 Apr 21, 2024
882c318
fix phpcs
yssambare12 Apr 21, 2024
e077508
chore: added new function to sanitize svg
yssambare12 Apr 22, 2024
c077a08
run phpcbf
yssambare12 Apr 22, 2024
410ab9f
Update admin/dashboard/assets/src/dashboard-app/pages/fonts/LocalFont.js
yssambare12 Apr 22, 2024
092d31d
Update admin/dashboard/assets/src/dashboard-app/pages/fonts/LocalFont.js
yssambare12 Apr 22, 2024
cd717e0
Update admin/dashboard/assets/src/dashboard-app/pages/fonts/edit/Edit…
yssambare12 Apr 22, 2024
7abe72f
Update admin/dashboard/assets/src/dashboard-app/pages/fonts/edit/Edit…
yssambare12 Apr 22, 2024
fe1b02d
Update admin/dashboard/includes/class-bsf-custom-fonts-menu.php
yssambare12 Apr 22, 2024
39e27ff
chore: translatable alter string updated
yssambare12 Apr 22, 2024
c30645b
chore:run phpcbf
yssambare12 Apr 22, 2024
58a9e6e
chore:added ignore comments for phpcs
yssambare12 Apr 22, 2024
11041ce
run phpcbf
yssambare12 Apr 22, 2024
eba6bb9
added ignore comments
yssambare12 Apr 22, 2024
e914305
added ignore comments
yssambare12 Apr 22, 2024
5d7b0c1
changelog added
yssambare12 Apr 22, 2024
12097fd
Update README.md
yssambare12 Apr 22, 2024
74036a4
chore: updated version and readme.md
yssambare12 Apr 22, 2024
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Tags:** typography, fonts, custom fonts, Google Fonts, performance, privacy, full site editing, adobe fonts, GDPR
**Requires at least:** 5.0
**Tested up to:** 6.5
**Stable tag:** 2.1.4
**Stable tag:** 2.1.5
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -151,6 +151,9 @@ Yes, Custom Fonts is completely free to use, without any limitation.


## Changelog ##
### 2.1.5 ###
- Improved codebase for improved security.

### 2.1.4 ###
- Improvement: Compatibility with WordPress 6.5.

Expand Down
23 changes: 18 additions & 5 deletions admin/dashboard/assets/src/dashboard-app/pages/fonts/LocalFont.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,26 @@ const LocalVariationItem = ({
}
);

//loop through the array and do things with each attachment
//loop through the array and do things with each attachment & Validate file extensions.
let fontFileNames = [];
for (let i = 0; i < attachments.length; ++i) {
fontFileNames.push(attachments[i].attributes.url);
// Check if the file extension is allowed
const allowedExtensions = ['.ttf', '.otf', '.woff', '.woff2', '.eot', '.svg'];
const fileName = attachments[i].attributes.url.toLowerCase();
const extension = fileName.substr(fileName.lastIndexOf('.'));
if (allowedExtensions.includes(extension)) {
fontFileNames.push(attachments[i].attributes.url);
} else {
// Reject the file upload and display an error message
alert(
__(
"Invalid file type. Only .ttf, .otf, .woff, .woff2, .svg files are allowed.",
"custom-fonts"
)
);
return;
}
}

setFontFileName( fontFileNames );
handleVariationChange(
event,
Expand All @@ -58,10 +72,9 @@ const LocalVariationItem = ({
fontFileNames
);
});

// Finally, open the modal on click
frame.open();
}
};

const expandFileField = (e) => {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,26 @@ const EditLocalVariationItem = ({
}
);

//loop through the array and do things with each attachment
//loop through the array and do things with each attachment & Validate file extensions.
let fontFileNames = [];
for (let i = 0; i < attachments.length; ++i) {
fontFileNames.push(attachments[i].attributes.url);
// Check if the file extension is allowed
const allowedExtensions = ['.ttf', '.otf', '.woff', '.woff2', '.eot', '.svg'];
const fileName = attachments[i].attributes.url.toLowerCase();
const extension = fileName.substr(fileName.lastIndexOf('.'));
if (allowedExtensions.includes(extension)) {
fontFileNames.push(attachments[i].attributes.url);
} else {
// Reject the file upload and display an error message
alert(
__(
'Invalid file type. Only .ttf, .otf, .woff, .woff2, .svg files are allowed.',
'custom-fonts'
)
);
return;
}
}

setFontFileName( fontFileNames );
handleVariationChange(
event,
Expand All @@ -63,10 +77,9 @@ const EditLocalVariationItem = ({
fontFileNames
);
});

// Finally, open the modal on click
frame.open();
}
};

const expandFileField = (e) => {
e.preventDefault();
Expand Down
Loading
Loading