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

Use character set instead of regex for string sanitizer #46

Merged
merged 6 commits into from
Oct 24, 2016

Conversation

SergeyKuryanov
Copy link
Contributor

@SergeyKuryanov SergeyKuryanov commented Oct 20, 2016

This address issue #45

Seems like regex do not replace all characters. Here is an example:

Source: A-Za-z0-9.:-_<>:"'][{}!@#$%^&*()_+œ∑´®†¥¨ˆøπ“
Regex: A-Za-z0-9.:-_<>:--][---@---^----_------------
Expected: A-Za-z0-9.:-_--:----------------_------------

Explicit set is used to avoid non latin letters or symbols like åß^

@adamyanalunas please inspect

@adamyanalunas
Copy link
Contributor

What about some tests to confirm these changes work?

@SergeyKuryanov
Copy link
Contributor Author

@adamyanalunas how about now?


@implementation NSString (AYLSanitizedForMetric)

- (NSString *)ayl_sanitizedForMetric
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not something like lib_santizedForMetric (Librato) or lm_sanitizedForMetric (Librato Metric) or alm_santizedForMetric (Amco Librato Metric)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to avoid two letter prefix. AYL was choosen by your initials and L for librato. But can rename to any other.

@@ -57,6 +57,7 @@
71FE433FB985CA1AB0DF6BDA /* Pods-librato-iOS Demo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-librato-iOS Demo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-librato-iOS Demo/Pods-librato-iOS Demo.debug.xcconfig"; sourceTree = "<group>"; };
B3CFB32942D9D0C3245EEB4E /* Pods-librato-iOS Demo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-librato-iOS Demo.release.xcconfig"; path = "Pods/Target Support Files/Pods-librato-iOS Demo/Pods-librato-iOS Demo.release.xcconfig"; sourceTree = "<group>"; };
C5A2D3C7197B48C6A9ACC07D /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
D9263DD61DB946660035CC6E /* NSString+AULSanitizedForMetricTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+AULSanitizedForMetricTests.m"; sourceTree = "<group>"; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean "AUL" to be "AYL"? If so, same questions about naming.

@SergeyKuryanov
Copy link
Contributor Author

@adamyanalunas how about now?

@adamyanalunas
Copy link
Contributor

When I run the tests it looks like nothing happens. I set a breakpoint in testThatOnlyAllowedCharactersPresent that doesn't get hit and the console has this:

Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds

@SergeyKuryanov
Copy link
Contributor Author

@adamyanalunas sorry for this, fixed.

@SergeyKuryanov SergeyKuryanov merged commit dac274d into master Oct 24, 2016
@SergeyKuryanov SergeyKuryanov deleted the 45_improve_string_sanitizer branch October 24, 2016 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants