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

Fall back on CoreFoundation for some core NSString/NSCFString behaviours #671

Merged
merged 6 commits into from
Jul 21, 2016

Conversation

DHowett-MSFT
Copy link

This reimplements some of _NSCFString's internals in terms of non-backstore-checking CF internal implementations exposed in ForFoundationOnly.h.
As a result, we now throw range/length exceptions and properly catch string mutability without exploding.

It also replaces our home-grown strings format parser with CoreFoundation's tried/true one.

Additionally, printing an object via NSString's %@ format specifier will prefer -description instead of CFShow() for Objective-C types.

@DHowett-MSFT
Copy link
Author

@ms-jihua is added to the review. #Closed

@DHowett-MSFT
Copy link
Author

@bbowman is added to the review. #Closed

StringsFormatPropertyList,
::testing::Values(L"\uFEFFkey1=value1;\n\"key2\"=\"value2\";", // BOM
L"key1=value1;\n\"key2\"=\"value2\";" // No BOM
));
Copy link
Member

@bbowman bbowman Jul 20, 2016

Choose a reason for hiding this comment

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

This is so cool!!!!! #Closed

Copy link
Author

Choose a reason for hiding this comment

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

Glad you think so! I used some of the other NSString tests as inspiration.


In reply to: 71446495 [](ancestors = 71446495)

@bbowman
Copy link
Member

bbowman commented Jul 20, 2016

:shipit:

TEST(NSString, Exceptions) {
NSRange range{ 100, 10 };

EXPECT_ANY_THROW([@"hello" characterAtIndex:10]);
Copy link
Contributor

@rajsesh rajsesh Jul 20, 2016

Choose a reason for hiding this comment

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

EXPECT_ANY_THROW [](start = 4, length = 16)

Do these tests work on ARM? #Closed

Copy link
Author

Choose a reason for hiding this comment

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

I've been caught! Probably not. I'll throw them into ARM_DISABLED_TESTS.


In reply to: 71574294 [](ancestors = 71574294)

Copy link
Author

Choose a reason for hiding this comment

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

These tests actually do work on ARM, puzzlingly.


In reply to: 71574787 [](ancestors = 71574787,71574294)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for checking. A wise man once said "Its always good to ask".


In reply to: 71600230 [](ancestors = 71600230,71574787,71574294)

@rajsesh
Copy link
Contributor

rajsesh commented Jul 20, 2016

:shipit:

@DHowett-MSFT DHowett-MSFT force-pushed the 201605-CFString-internal branch from acc5804 to a8a1587 Compare July 21, 2016 18:36
@DHowett-MSFT
Copy link
Author

In CI Build!

@DHowett-MSFT DHowett-MSFT force-pushed the 201605-CFString-internal branch from a8a1587 to 5025d2d Compare July 21, 2016 18:39
@DHowett-MSFT
Copy link
Author

Failed an application launch test. -[NSString isAbsolutePath] is blindly pulling characters without bounds checking, and will now throw an exception when it does so.

Addressing in an additional commit.

}

if (self.length >= 2) {
return _isLetter([self characterAtIndex:0]) && [self characterAtIndex:1] == ':';
Copy link
Author

Choose a reason for hiding this comment

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

This function is technically wrong, because C:Hello.txt is a relative path, not an absolute one.

Fixing it is out-of-scope for this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Talked to DHowett offline, he's going to take a closer look at drive paths next iteration, and leave this slightly-wrong state for now.

Be sure to add a comment about this status.

@@ -537,6 +537,10 @@ - (BOOL)getBytes:(void*)buffer
@Status Interoperable
*/
- (void)getCharacters:(unichar*)dest range:(NSRange)range {
if (range.location + range.length > self.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

surprised we didn't have this check already. use NSLocationInRange instead, though?

Copy link
Author

Choose a reason for hiding this comment

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

We don't exactly want that here; if length is 5, NSLocationInRange(5, {1,2}) will be false but that doesn't make this invalid.

@DHowett-MSFT
Copy link
Author

Submitting a new CI build with the updates, just to make sure.

@DHowett-MSFT
Copy link
Author

Passed CI build and application launch tests.

@DHowett-MSFT DHowett-MSFT merged commit e82015d into microsoft:develop Jul 21, 2016
@DHowett-MSFT DHowett-MSFT deleted the 201605-CFString-internal branch July 21, 2016 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants