-
Notifications
You must be signed in to change notification settings - Fork 9
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(media): should not have files that begin with underscore #1819
fix(media): should not have files that begin with underscore #1819
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @kishore03109 and the rest of your teammates on Graphite |
.test( | ||
"File not supported", | ||
"File names cannot begin with an underscore", | ||
(value) => { | ||
return !value.startsWith("_") | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this is only a check for the user-provided name yeah? On the backend I believe we convert special characters into _
, so something like !!image.jpg
will be converted to __image.jpg
and bypass this check. I think we might either need to tighten up this check to block starting with special characters entirely, or move this check to the backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a frontend thing. keeping the rules consistent for both image upload and renames
9015204
to
d28f9b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, small comment about allowing numbers
d28f9b9
to
74aa4e0
Compare
74aa4e0
to
724a5d7
Compare
* fix(media): should not have files that begin with underscore (#1819) ## Problem currently files that start with _ are ignored. this means that in the final output, the site does not have the broken link. this issue is quite existent in our sites (eg. https://www.cdc.gov.sg/our-programmes/gallery/2021/) when i did a string search, this lead to quite a number of sites with these types of images. this is not ideal, and as such this edge case will be coded out as part of the link checker for user to fix Tests - [ ] enter into a repo and try to rename an image into something with an leading underscore. - [ ] asset that you get the error message as shown below ![Screenshot 2024-03-05 at 2 03 20 PM](https://github.com/isomerpages/isomercms-frontend/assets/42832651/95fbccc9-aa7e-4fae-831c-2ccbb236c8c7) - [ ] upload an image named '_name.png' into the images folder. assert that the leading underscore gets stripped off https://github.com/isomerpages/isomercms-frontend/assets/42832651/1ce91503-04b0-442e-8fef-10ae99e3129c * fix(sanitiseUrl): fix limitations with library (#1821) ## Problem The sanitize-url library does filters HTML entities, but it does not do so recursively. By nesting HTML entities, it is possible to create a URL which specifies the JavaScript protocol handler. Closes GTA-24-006 ## Solution Handroll a quick url constructor and check that the protocols are adhered to. **Breaking Changes** <!-- Does this PR contain any backward incompatible changes? If so, what are they and should there be special considerations for release? --> - [ ] Yes - this PR contains breaking changes - Details ... - [X] No - this PR is backwards compatible with ALL of the following feature flags in this [doc](https://www.notion.so/opengov/Existing-feature-flags-518ad2cdc325420893a105e88c432be5) ## Tests <!-- What tests should be run to confirm functionality? --> - [ ] Login via github and visit "http://localhost:3000/sites/kishore-test-dev-gh/contact-us" - [ ] when hovering over `[+65 6123 4589](tel:+6561234589)` verify that it links to `tel:+6561234589` - [ ] when hovering over `[[email protected]](mailto:[email protected])` verify that it links to `[email protected]` - [ ] when hovering over `[online form](https://www.form.gov.sg/)` verify that it links to `https://www.form.gov.sg/` <img width="533" alt="Screenshot 2024-03-05 at 1 10 36 PM" src="https://github.com/isomerpages/isomercms-frontend/assets/42832651/87c5edbb-8744-47d1-8b9d-01f38893dc15"> * 0.81.0 --------- Co-authored-by: Alexander Lee <[email protected]> Co-authored-by: Kishore <[email protected]>
Problem
currently files that start with _ are ignored. this means that in the final output, the site does not have the broken link.
this issue is quite existent in our sites (eg. https://www.cdc.gov.sg/our-programmes/gallery/2021/)
when i did a string search, this lead to quite a number of sites with these types of images. this is not ideal, and as such this edge case will be coded out as part of the link checker for user to fix
Tests
Screen.Recording.2024-03-05.at.2.03.51.PM.mov