Comments (3)
How about fileName.replaceAll("[\\\\/:*?\"<>|]", "")
This actually just targets the illegal characters, so it works subtractively rather than only allowing the chars here. It would allow spaces but also disallow certain characters. Is this too permissive?
the fix to keep the existing pattern would be:
filename.replaceAll("/[^a-zA-Z0-9 ]/", "")
. Looks similar but there's a space after the 9, but that wouldn't trim leading and trailing spaces, so I think Java has a .trim() method for that? so like:
filename.replaceAll("/[^a-zA-Z0-9 ]/", "").trim()
As for repeated spaces... I know it would be slick to do it all in one regex but if we added .replaceAll("\\s+"," ")
to the end that would remove any runs of more than one space, too.
Not 100% sure how to write that all as a single regex, but
return filename.replaceAll("/[^a-zA-Z0-9 ]/", "").trim().replaceAll("\\s+"," ");
...i think would be ok
from owlplug.
Thank you for your suggestions. I've updated the function to allow spaces in filenames.
I've also added a few unit tests to ensure the behaviour is correct.
from owlplug.
Fix released in OwlPlug 0.15.0
from owlplug.
Related Issues (20)
- Load JavaFx from the Java module-path
- Directory-based audio plugins can't be disabled HOT 1
- Distribution with package managers HOT 3
- [feat] generate a folder structure based on the plugin information HOT 1
- LV2 support HOT 6
- Enable OwlPlug Scanner by default for plugin synchronization
- Refresh Options tab when the user data is cleared to reflect changes
- Unable to be installed on Mac M1 HOT 1
- Export installed plugins to CSV, json format HOT 1
- This app is blocked! Seriousely?! HOT 5
- Damaged app HOT 1
- Subcomponent and WavesShell support HOT 1
- `lxvst` is not a valid vst dir on linux HOT 2
- Allow adding additional plugin directories per format HOT 1
- Additional LV2 dirs are not scanned (Linux) HOT 4
- Provide alternative installers for linux HOT 2
- 1.22.1 Distribution flagged as Damaged by OS 12.6.1 (Monterey) HOT 4
- Abort a running task from UI
- MacOS - Cant run project from source / how did you manage to delete files without read & write permission HOT 12
- Support multiple type of archives on remote sources HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from owlplug.