Bug 187859 - WebCore::URL::hostIsIPAddress needs a Windows implementation
Summary: WebCore::URL::hostIsIPAddress needs a Windows implementation
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ross Kirsling
URL:
Keywords: InRadar
Depends on: 187864
Blocks:
  Show dependency treegraph
 
Reported: 2018-07-20 09:22 PDT by Ross Kirsling
Modified: 2018-07-24 08:16 PDT (History)
6 users (show)

See Also:


Attachments
Patch (5.41 KB, patch)
2018-07-23 17:28 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (6.19 KB, patch)
2018-07-23 23:23 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Kirsling 2018-07-20 09:22:55 PDT
Currently on non-Cocoa, non-libsoup platforms, URL::hostIsIPAddress is just a stub:
https://github.com/WebKit/webkit/blob/767a0672697c45f01acb22e3fe00ff1f5c97871c/Source/WebCore/platform/URL.cpp#L1064-L1070

Not sure why it lacks a "FIXME", but this ought to be a default implementation, so that Windows ports can use it.
Comment 1 Ross Kirsling 2018-07-23 17:28:33 PDT
Created attachment 345627 [details]
Patch
Comment 2 Fujii Hironori 2018-07-23 19:06:18 PDT
Comment on attachment 345627 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=345627&action=review

> Source/WebCore/platform/URL.cpp:1082
> +            if (digit > '9' || digit < (i ? '1' : '0'))

This loop scans backward. If i == 0, it is the last number. You want to check the first number here. It should be "(i == length - 1 ? '1' : '0')"

> Source/WebCore/platform/URL.cpp:1085
> +            value += 10 * (digit - '0');

This is not correct. For example, a number '123' is given.
value = 0;
value += 10 * 3;
value += 10 * 2;
value += 10 * 1;
Then value becomes 60, not 123.
Comment 3 Ross Kirsling 2018-07-23 23:23:21 PDT
Created attachment 345637 [details]
Patch
Comment 4 Ross Kirsling 2018-07-23 23:30:08 PDT
Sorry, those really were some stupid mistakes on my part.
It seems that ultimately forward iteration is the most straightforward here. I've also added a few extra test cases for IPv4 accordingly.
Comment 5 WebKit Commit Bot 2018-07-24 08:15:42 PDT
Comment on attachment 345637 [details]
Patch

Clearing flags on attachment: 345637

Committed r234147: <https://trac.webkit.org/changeset/234147>
Comment 6 WebKit Commit Bot 2018-07-24 08:15:43 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2018-07-24 08:16:19 PDT
<rdar://problem/42541837>