WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
118003
[Mac] Document URL is not updated by HSTS
https://bugs.webkit.org/show_bug.cgi?id=118003
Summary
[Mac] Document URL is not updated by HSTS
Alexey Proskuryakov
Reported
2013-06-25 16:33:49 PDT
When opening an HTTP link to an HSTS enabled site, WebKit does not update document URL, so window.location remains an http one. <
rdar://problem/14241270
>
Attachments
proposed fix
(4.01 KB, patch)
2013-06-25 16:38 PDT
,
Alexey Proskuryakov
no flags
Details
Formatted Diff
Diff
Patch v2 - Bigger patch, more shared code.
(17.18 KB, patch)
2013-06-25 17:23 PDT
,
Brady Eidson
no flags
Details
Formatted Diff
Diff
Patch v3 - Cleaner
(17.27 KB, patch)
2013-06-25 17:41 PDT
,
Brady Eidson
ap
: review+
buildbot
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2013-06-25 16:38:29 PDT
Created
attachment 205430
[details]
proposed fix
Brady Eidson
Comment 2
2013-06-25 16:45:44 PDT
Comment on
attachment 205430
[details]
proposed fix View in context:
https://bugs.webkit.org/attachment.cgi?id=205430&action=review
> Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm:80 > +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 > + // <
rdar://problem/14241270
>: Synthesize a response for HSTS. > + if (!redirectResponse && ![[[newRequest URL] scheme] isEqualToString:[[[connection currentRequest] URL] scheme]]) { > + NSDictionary *synthesizedResponseHeaderFields = @{ @"Location": [[newRequest URL] absoluteString], @"Cache-Control": @"no-store" }; > + redirectResponse = [[[NSHTTPURLResponse alloc] initWithURL:[[connection currentRequest] URL] statusCode:302 HTTPVersion:(NSString *)kCFHTTPVersion1_1 headerFields:synthesizedResponseHeaderFields] autorelease]; > + } > +#endif
This exact same code is copied below in WebCoreResourceHandelAsOperationQueueDelegate.mm. Are you sure we can't find a suitable place to share it?
> Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:121 > +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 > + if (!redirectResponse && ![[[newRequest URL] scheme] isEqualToString:[[[connection currentRequest] URL] scheme]]) { > + NSDictionary *synthesizedResponseHeaderFields = @{ @"Location": [[newRequest URL] absoluteString], @"Cache-Control": @"no-store" }; > + redirectResponse = [[[NSHTTPURLResponse alloc] initWithURL:[[connection currentRequest] URL] statusCode:302 HTTPVersion:(NSString *)kCFHTTPVersion1_1 headerFields:synthesizedResponseHeaderFields] autorelease]; > + } > +#endif
Except in this copy there's no comment pointing to the radar. I like the comment, and think it should be wherever this code is. And, I think that this code should be in precisely one place... :)
Brady Eidson
Comment 3
2013-06-25 17:23:50 PDT
Created
attachment 205431
[details]
Patch v2 - Bigger patch, more shared code.
WebKit Commit Bot
Comment 4
2013-06-25 17:25:53 PDT
Attachment 205431
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/WebCore.xcodeproj/project.pbxproj', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.h', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.mm', u'Source/WebCore/platform/network/mac/ResourceHandleMac.mm', u'Source/WebCore/platform/network/mac/ResourceResponseMac.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.h', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.mm']" exit_code: 1 Source/WebCore/platform/network/mac/MacNetworkingExtras.h:32: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Brady Eidson
Comment 5
2013-06-25 17:28:10 PDT
(In reply to
comment #4
)
>
Attachment 205431
[details]
did not pass style-queue: > > Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/WebCore.xcodeproj/project.pbxproj', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.h', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.mm', u'Source/WebCore/platform/network/mac/ResourceHandleMac.mm', u'Source/WebCore/platform/network/mac/ResourceResponseMac.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.h', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.mm']" exit_code: 1 > Source/WebCore/platform/network/mac/MacNetworkingExtras.h:32: Extra space before ( in function call [whitespace/parens] [4] > Total errors found: 1 in 8 files > > > If any of these errors are false positives, please file a bug against check-webkit-style.
Fixed locally.
Brady Eidson
Comment 6
2013-06-25 17:29:04 PDT
(In reply to
comment #5
)
> (In reply to
comment #4
) > >
Attachment 205431
[details]
[details] did not pass style-queue: > > > > Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/WebCore.xcodeproj/project.pbxproj', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.h', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.mm', u'Source/WebCore/platform/network/mac/ResourceHandleMac.mm', u'Source/WebCore/platform/network/mac/ResourceResponseMac.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.h', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.mm']" exit_code: 1 > > Source/WebCore/platform/network/mac/MacNetworkingExtras.h:32: Extra space before ( in function call [whitespace/parens] [4] > > Total errors found: 1 in 8 files > > > > > > If any of these errors are false positives, please file a bug against check-webkit-style. > > Fixed locally.
Errrrr..... nevermind - bogus check-webkit-style not understand ObjC categories vs. function calls.
Alexey Proskuryakov
Comment 7
2013-06-25 17:32:10 PDT
Comment on
attachment 205431
[details]
Patch v2 - Bigger patch, more shared code. View in context:
https://bugs.webkit.org/attachment.cgi?id=205431&action=review
> Source/WebCore/platform/network/mac/MacNetworkingExtras.h:39 > +@class NSURLConnection; > +@class NSURLRequest; > +@class NSURLResponse;
This header doesn't look like it's Objective-C only (there is #ifdef __OBJC__).
> Source/WebCore/platform/network/mac/MacNetworkingExtras.h:42 > +void synthesizeRedirectResponseIfNecessary(NSURLConnection *, NSURLRequest *newRequest, NSURLResponse **redirectResponse);
Can the synthesized response be returned normally?
> Source/WebCore/platform/network/mac/MacNetworkingExtras.mm:326 > +#ifdef __OBJC__
Inside a .mm file?!
> Source/WebCore/platform/network/mac/MacNetworkingExtras.mm:332 > + ASSERT_UNUSED(redirectResponse, redirectResponse); > +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 > + UNUSED_PARAM(connection); > + UNUSED_PARAM(newRequest);
This seems inconsistent, ASSERT_UNUSED is also not always unused.
Brady Eidson
Comment 8
2013-06-25 17:36:24 PDT
(In reply to
comment #7
)
> (From update of
attachment 205431
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=205431&action=review
> > > Source/WebCore/platform/network/mac/MacNetworkingExtras.h:39 > > +@class NSURLConnection; > > +@class NSURLRequest; > > +@class NSURLResponse; > > This header doesn't look like it's Objective-C only (there is #ifdef __OBJC__).
And these @class forward decls are in the #ifdef __OBJC__ block for that reason!
> > Source/WebCore/platform/network/mac/MacNetworkingExtras.h:42 > > +void synthesizeRedirectResponseIfNecessary(NSURLConnection *, NSURLRequest *newRequest, NSURLResponse **redirectResponse); > > Can the synthesized response be returned normally?
Probably.
> > > Source/WebCore/platform/network/mac/MacNetworkingExtras.mm:326 > > +#ifdef __OBJC__ > > Inside a .mm file?!
heh.
> > > Source/WebCore/platform/network/mac/MacNetworkingExtras.mm:332 > > + ASSERT_UNUSED(redirectResponse, redirectResponse); > > +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 > > + UNUSED_PARAM(connection); > > + UNUSED_PARAM(newRequest); > > This seems inconsistent, ASSERT_UNUSED is also not always unused.
The assert makes sense 100% of the time with the current method signature, but taking your earlier feedback this will change.
Brady Eidson
Comment 9
2013-06-25 17:41:12 PDT
Created
attachment 205432
[details]
Patch v3 - Cleaner
WebKit Commit Bot
Comment 10
2013-06-25 17:43:03 PDT
Attachment 205432
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/WebCore.xcodeproj/project.pbxproj', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.h', u'Source/WebCore/platform/network/mac/MacNetworkingExtras.mm', u'Source/WebCore/platform/network/mac/ResourceHandleMac.mm', u'Source/WebCore/platform/network/mac/ResourceResponseMac.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.h', u'Source/WebCore/platform/network/mac/WebCoreURLResponse.mm']" exit_code: 1 Source/WebCore/platform/network/mac/MacNetworkingExtras.h:32: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 11
2013-06-25 18:04:59 PDT
Comment on
attachment 205432
[details]
Patch v3 - Cleaner
Attachment 205432
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/946210
Alexey Proskuryakov
Comment 12
2013-06-25 18:49:16 PDT
Comment on
attachment 205432
[details]
Patch v3 - Cleaner View in context:
https://bugs.webkit.org/attachment.cgi?id=205432&action=review
r=me. Please fix the build before landing.
> Source/WebCore/ChangeLog:15 > + * platform/network/mac/MacNetworkingExtras.h: Renamed from Source/WebCore/platform/network/mac/WebCoreURLResponse.h.
This file name doesn't make me happy, it's so non-descriptive.
> Source/WebCore/platform/network/mac/MacNetworkingExtras.mm:328 > +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
We usually put "new" code first.
> Source/WebCore/platform/network/mac/MacNetworkingExtras.mm:334 > + if (!redirectResponse && ![[[newRequest URL] scheme] isEqualToString:[[[connection currentRequest] URL] scheme]]) {
I think that this would be easier to read with an early return: if (redirectResponse) return redirectResponse; if (long condition) ...
Brady Eidson
Comment 13
2013-06-26 09:21:32 PDT
(In reply to
comment #12
)
> > Source/WebCore/ChangeLog:15 > > + * platform/network/mac/MacNetworkingExtras.h: Renamed from Source/WebCore/platform/network/mac/WebCoreURLResponse.h. > > This file name doesn't make me happy, it's so non-descriptive.
The more I think about it, the addition of "synthesizeRedirectResponseIfNecessary" fits in with the previous theme of the header. Maybe it doesn't need a name change at all.
Brady Eidson
Comment 14
2013-06-26 10:04:30 PDT
http://trac.webkit.org/changeset/151994
Alexey Proskuryakov
Comment 15
2013-06-26 10:09:18 PDT
The code you add is about NSURLConnection, so having it in WebCoreURLResponse.h is not right. Consider a different API where the fact that HSTS mutated the request is explicitly communicated, and we don't have to guess like this. The code would be all different, despite NSURLResponse remaining unchanged.
Brady Eidson
Comment 16
2013-06-26 10:43:57 PDT
(In reply to
comment #15
)
> The code you add is about NSURLConnection, so having it in WebCoreURLResponse.h is not right.
The code I added refers to NSURLConnection, yes. It also refers to NSURLResponse. But it's core purpose is about fixing a response object to meet WebCore's expectations inside delegate callbacks. I see no difference between this and the purpose of adjustMIMETypeIfNecessary. While I wholeheartedly agree that "WebCoreURLResponse" is not a great name for this header, I would suggest that it was a poor name before this patch, and it is no worse a name after this patch.
> Consider a different API where the fact that HSTS mutated the request is explicitly communicated, and we don't have to guess like this. The code would be all different, despite NSURLResponse remaining unchanged.
I don't think this file is explicitly about NSURLResponse.
Brady Eidson
Comment 17
2013-06-26 10:44:52 PDT
I'm definitely open to a better name than WebCoreURLResponse, and would gladly do the rename in a followup. I just think that this patch is inline with the previous purpose of the header, and makes the poor name no worse.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug