WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
54594
Expose isValidProtocol() in KURL.h.
https://bugs.webkit.org/show_bug.cgi?id=54594
Summary
Expose isValidProtocol() in KURL.h.
James Kozianski
Reported
2011-02-16 15:26:41 PST
Expose isValidProtocol() in KURL.h.
Attachments
Patch
(3.00 KB, patch)
2011-02-16 15:27 PST
,
James Kozianski
no flags
Details
Formatted Diff
Diff
Patch
(3.11 KB, patch)
2011-02-16 15:44 PST
,
James Kozianski
no flags
Details
Formatted Diff
Diff
Patch
(3.23 KB, patch)
2011-03-06 20:39 PST
,
James Kozianski
no flags
Details
Formatted Diff
Diff
Patch
(2.86 KB, patch)
2011-03-07 15:46 PST
,
James Kozianski
koz
: review-
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
James Kozianski
Comment 1
2011-02-16 15:27:22 PST
Created
attachment 82710
[details]
Patch
James Kozianski
Comment 2
2011-02-16 15:32:15 PST
The implementation of isValidProtocol() in KURLGoogle.cpp is basically a copy/paste of the one in KURL.cpp - I'm not sure if this is kosher from a code duplication or plagiarism point of view (the function is quite trivial and any reasonable implementation would be isomorphic to the original) so any guidance on this matter would be appreciated.
Adam Barth
Comment 3
2011-02-16 15:37:52 PST
Comment on
attachment 82710
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=82710&action=review
> Source/WebCore/ChangeLog:7 > + Expose isValidProtocol() in KURL.h. > +
https://bugs.webkit.org/show_bug.cgi?id=54594
> +
Why?
James Kozianski
Comment 4
2011-02-16 15:42:09 PST
(In reply to
comment #3
)
> (From update of
attachment 82710
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=82710&action=review
> > > Source/WebCore/ChangeLog:7 > > + Expose isValidProtocol() in KURL.h. > > +
https://bugs.webkit.org/show_bug.cgi?id=54594
> > + > > Why?
For general use, but in particular because I want to check for invalid schemes being used in calls to navigator.registerProtocolHandler (see
bug 54438
). Sorry, I'll add that to the ChangeLog.
James Kozianski
Comment 5
2011-02-16 15:44:44 PST
Created
attachment 82714
[details]
Patch
Adam Barth
Comment 6
2011-02-16 23:28:49 PST
CCing URL folks
Alexey Proskuryakov
Comment 7
2011-02-16 23:46:10 PST
Should we rename this to isValidProtocolName() when exposing? Or even isValidSchemeName()?
Eric Seidel (no email)
Comment 8
2011-02-17 01:49:03 PST
Comment on
attachment 82714
[details]
Patch This seems tricky. How flexible should this be? Should this allow leading/trailing spaces? Why is this only implemented for the Google side? is "a" a valid scheme? Seems this says it is. Can we test this?
James Kozianski
Comment 9
2011-02-17 13:14:06 PST
(In reply to
comment #8
)
> (From update of
attachment 82714
[details]
) > This seems tricky. How flexible should this be? Should this allow leading/trailing spaces? Why is this only implemented for the Google side? is "a" a valid scheme? Seems this says it is. Can we test this?
There is already an implementation in KURL.cpp of which this is just a copy (see my above comment). And I think the most intuitive behaviour for this function would be to validate exactly what the spec says at
http://tools.ietf.org/html/rfc3986#section-3.1
. As for testing, this function isn't exposed to the browser directly (it is used internally by KURL.cpp), but in my other patch (
bug 54438
) which causes navigator.registerProtocolHandler() to use this function to verify protocols passed to it, I add test cases that exercise this function directly.
James Kozianski
Comment 10
2011-02-17 13:24:34 PST
(In reply to
comment #7
)
> Should we rename this to isValidProtocolName() when exposing? Or even isValidSchemeName()?
I think its current name is the most consistent - the current public interface for KURL uses 'protocol' by itself (protocolIs(), setProtocol(), etc). Also, it could be argued that in the context of a URL it is implied that we are referring to the name of a protocol.
Alexey Proskuryakov
Comment 11
2011-02-17 13:36:28 PST
> I think its current name is the most consistent - the current public interface for KURL uses 'protocol' by itself (protocolIs(), setProtocol(), etc).
OK.
> Also, it could be argued that in the context of a URL it is implied that we are referring to the name of a protocol.
This I don't agree with. KURL knows a lot about semantics of URLs (even default ports!), so it's not always about names.
James Kozianski
Comment 12
2011-02-17 16:59:32 PST
(In reply to
comment #11
)
> > Also, it could be argued that in the context of a URL it is implied that we are referring to the name of a protocol. > > This I don't agree with. KURL knows a lot about semantics of URLs (even default ports!), so it's not always about names.
True, that's a good point.
Ojan Vafai
Comment 13
2011-02-21 21:35:23 PST
Comment on
attachment 82714
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=82714&action=review
> Source/WebCore/platform/KURLGoogle.cpp:136 > +bool isValidProtocol(const String& protocol)
This is missing a comment from the KURL.cpp version. May as well make the copy-paste exact. Also, can you put a comment explaining that this is copy-pasted from there?
James Kozianski
Comment 14
2011-03-06 20:35:04 PST
(In reply to
comment #13
)
> (From update of
attachment 82714
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=82714&action=review
> > > Source/WebCore/platform/KURLGoogle.cpp:136 > > +bool isValidProtocol(const String& protocol) > > This is missing a comment from the KURL.cpp version. May as well make the copy-paste exact. Also, can you put a comment explaining that this is copy-pasted from there?
Done.
James Kozianski
Comment 15
2011-03-06 20:39:41 PST
Created
attachment 84917
[details]
Patch
Adam Barth
Comment 16
2011-03-06 20:51:48 PST
dave_levin have been working to remove duplicated code in KURL.cpp and KURLGoogle.cpp. I noticed this comment: + // NOTE This is a copy of the function in KURL.cpp. Maybe we can move this function outside the ifdef so we don't have to copy/paste it?
David Levin
Comment 17
2011-03-06 22:24:24 PST
(In reply to
comment #16
)
> dave_levin have been working to remove duplicated code in KURL.cpp and KURLGoogle.cpp. I noticed this comment: > > + // NOTE This is a copy of the function in KURL.cpp. > > Maybe we can move this function outside the ifdef so we don't have to copy/paste it?
Yes, please do (see the bottom of KURL.cpp). (It seems silly to duplicate code between these two files for things that are identical so I got rid of some. Let's not add more.)
David Levin
Comment 18
2011-03-06 22:24:48 PST
Comment on
attachment 84917
[details]
Patch Per above comment.
James Kozianski
Comment 19
2011-03-07 15:45:22 PST
(In reply to
comment #17
)
> (In reply to
comment #16
) > > dave_levin have been working to remove duplicated code in KURL.cpp and KURLGoogle.cpp. I noticed this comment: > > > > + // NOTE This is a copy of the function in KURL.cpp. > > > > Maybe we can move this function outside the ifdef so we don't have to copy/paste it? > > Yes, please do (see the bottom of KURL.cpp). (It seems silly to duplicate code between these two files for things that are identical so I got rid of some. Let's not add more.)
Right, of course. Done.
James Kozianski
Comment 20
2011-03-07 15:46:40 PST
Created
attachment 84991
[details]
Patch
James Kozianski
Comment 21
2011-03-07 15:52:23 PST
Comment on
attachment 84991
[details]
Patch Compile errors.
James Kozianski
Comment 22
2011-03-07 15:59:54 PST
(In reply to
comment #21
)
> (From update of
attachment 84991
[details]
) > Compile errors.
Hm. This is made a bit more complicated by the fact that the duplicated versions are identical in code, but because they are in different files they get linked with different static inline methods (see isSchemeChar() and isSchemeFirstChar() in KURL.cpp and KURLGoogle.cpp). What would be the best way to move forward here?
David Levin
Comment 23
2011-03-07 16:19:28 PST
(In reply to
comment #22
)
> (In reply to
comment #21
) > > (From update of
attachment 84991
[details]
[details]) > > Compile errors. > > Hm. This is made a bit more complicated by the fact that the duplicated versions are identical in code, but because they are in different files they get linked with different static inline methods (see isSchemeChar() and isSchemeFirstChar() in KURL.cpp and KURLGoogle.cpp). > > What would be the best way to move forward here?
If needed, you can do separate (duplicate) methods.
James Kozianski
Comment 24
2011-03-07 16:38:47 PST
> If needed, you can do separate (duplicate) methods.
Okay, I've revived the old patch as per our chat.
David Levin
Comment 25
2011-03-07 17:32:56 PST
Comment on
attachment 84917
[details]
Patch So sad but it seems we need to do this. If you get a better idea, feel free to submit another patch. Something to consider is moving those inline functions to KURL.h Anyway r+ on this.
WebKit Commit Bot
Comment 26
2011-03-08 09:41:30 PST
Comment on
attachment 84917
[details]
Patch Clearing flags on attachment: 84917 Committed
r80566
: <
http://trac.webkit.org/changeset/80566
>
WebKit Commit Bot
Comment 27
2011-03-08 09:41:37 PST
All reviewed patches have been landed. Closing bug.
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