Comments (1)
I'm not offering a PR this time (probably), but here is a bit of code:
bool tag_name_is_valid(const char* restrict str, size_t len)
{
// Rules as appear here:
// https://stackoverflow.com/a/26382358/1593077
// rule 1
if (str[0] == '.') { return false; }
if (strstr(str, "/.")) { return false; }
if (strstr(str, ".lock/")) { return false; }
if (strcmp(str + len - 5, ".lock") == 0) { return false; }
// rule 2 - unused, since theoretically we could have "allow-onelevel"
// if (strchr(str, '/') == NULL) { return false; }
// rule 3
if (strstr(str, "..")) { return false; }
// rule 4
for(size_t i; i < len; i++) {
char c = str[i];
bool is_ascii_control_char = (c < 0x20) || (c == 0x7F /* DEL */);
if (is_ascii_control_char || c == ' ' || c == '~' || c == '^' || c ==':' ) return false;
}
// rule 4
if ( (strpbrk(str, "?*[") != NULL) ) { return false; }
// rule 5
if ( (strpbrk(str, "?*[") != NULL) ) { return false; }
// rule 6
if ( (str[0]) || (str[len - 1] == '/') || (strstr(str, "//") != NULL) ) { return false; }
// rule 7
if (str[len - 1] == '.') { return false; }
// rule 8
if (strchr(str,"@{") != NULL) { return false; }
// rule 9
if (str[0] == '@' && len == 1) { return false; }
// rule 10
if (strchr(str, '\\') != NULL) { return false; }
return true;
}
from crap.
Related Issues (20)
- Problem importing CVS module HOT 13
- Relative path patch reverted HOT 2
- Leaving a dirty working tree after incremental import HOT 3
- New tip does not contain ... warning message HOT 4
- Does not compile with C99 HOT 5
- Segfault in fill_in_versions_and_parents() for version without '.' HOT 5
- Need a way to ignore CVS "cvs [update aborted]: invalid change text in ..." HOT 3
- Not an issue, just deep thank you! HOT 4
- A commit renaming a file with only a change of case breaks crap-clone on Cygwin HOT 4
- fatal error: pipeline.h: No such file or directory HOT 1
- crap fails to notice my password in .cvspas HOT 4
- Attempt to open a non-existent file HOT 2
- Support specifying a pserver password via the command-line
- Fails to get a specific revision of a specific file HOT 3
- `libpipeline-devel` is not available on Centos8 stream. HOT 1
- Crap should honor CVS repository syntax HOT 4
- crap-clone gives up when encountering "malformed version" HOT 7
- Does not compile on Mac OS X 10.9 HOT 4
- Relative paths to local CVS repositories 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 crap.