Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29351560: Issue 4395 - Setting page is loaded non-populated on some systems

Created:
Sept. 7, 2016, 7:44 a.m. by Oleksandr
Modified:
Sept. 8, 2016, 2:51 a.m.
Reviewers:
sergei, Eric
Visibility:
Public.

Description

Issue 4395 - Setting page is loaded non-populated on some systems. Account for cases when the settings URL is in form: file:///C:/Program%20Files/Adblock%20Plus%20for%20IE/html/templates/index.html while we expect it to be in directory: file:///C:/Program Files/Adblock Plus for IE/html/templates/

Patch Set 1 #

Total comments: 2

Patch Set 2 : Use 0 instead of NULL #

Total comments: 14

Patch Set 3 : Don't use UrlEscape and just compare unescaped canonical URLs #

Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -26 lines) Patch
M src/plugin/PluginTabBase.cpp View 1 2 2 chunks +6 lines, -8 lines 0 comments Download
M src/shared/Utils.h View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M src/shared/Utils.cpp View 1 2 2 chunks +8 lines, -17 lines 0 comments Download

Messages

Total messages: 6
Oleksandr
Sept. 7, 2016, 7:46 a.m. (2016-09-07 07:46:42 UTC) #1
sergei
Could you please provide with an example of the path when we need it? The ...
Sept. 7, 2016, 8:23 a.m. (2016-09-07 08:23:31 UTC) #2
Oleksandr
Patchset 1 - use 0 instead of NULL. Also modified the description to show what ...
Sept. 7, 2016, 9:13 a.m. (2016-09-07 09:13:43 UTC) #3
sergei
LGTM
Sept. 7, 2016, 9:15 a.m. (2016-09-07 09:15:27 UTC) #4
Eric
https://codereview.adblockplus.org/29351560/diff/29351566/src/plugin/PluginTabBase.cpp File src/plugin/PluginTabBase.cpp (right): https://codereview.adblockplus.org/29351560/diff/29351566/src/plugin/PluginTabBase.cpp#newcode160 src/plugin/PluginTabBase.cpp:160: dir = EscapeUrl(CanonicalizeUrl(dir)); There's no need to treat 'dir' ...
Sept. 7, 2016, 4:50 p.m. (2016-09-07 16:50:53 UTC) #5
Oleksandr
Sept. 8, 2016, 2:51 a.m. (2016-09-08 02:51:16 UTC) #6
NOTE: Since patchset 2 was already pushed, Patchset 3 and beyond would be a
separate commit.

https://codereview.adblockplus.org/29351560/diff/29351566/src/plugin/PluginTa...
File src/plugin/PluginTabBase.cpp (right):

https://codereview.adblockplus.org/29351560/diff/29351566/src/plugin/PluginTa...
src/plugin/PluginTabBase.cpp:160: dir = EscapeUrl(CanonicalizeUrl(dir));
On 2016/09/07 16:50:52, Eric wrote:
> There's no need to treat 'dir' as arising from a URL. It comes from a call to
> system API `GetModuleFileName` and will always be in standard Window path
> syntax. So at the very least calling `CanonicalizeUrl` here isn't necessary.
> 
> Besides, there's no reason to rewrite a static variable each time. If you
really
> want to compare in escaped URL form, just call `EscapeURL` in the
> definition/initialization statement in line 158.
> 
> And in addition, I don't see why we need to compare escaped strings in the
first
> place. We can conver the path in the URL to canonical Windows form and compare
> those. See comment in the definition of `CanonicalizeUrl` for how to do that.
Or
> just use the function we used to have that did that. We removed then function
> `UnescapeUrl` previously because it was interfering with the blocking
algorithm.
> That function could be used here. It was removed in change set
> 5531a44442cd29020a384dc99bdddc08656e560a, and it was already fully tested.

The thinking here is that Since dir arrives from a system call we cannot assume
it to be in any format, really. I think to be safe having Canonicalization here
would be fine.

https://codereview.adblockplus.org/29351560/diff/29351566/src/plugin/PluginTa...
src/plugin/PluginTabBase.cpp:161: std::wstring urlCanonicalized =
EscapeUrl(CanonicalizeUrl(url));
On 2016/09/07 16:50:52, Eric wrote:
> As a point of English usage, `urlCanonical` (with "canonical" as an adjective)
> is a little better. We don't need to care how it became canonical.

Done.

https://codereview.adblockplus.org/29351560/diff/29351566/src/plugin/PluginTa...
src/plugin/PluginTabBase.cpp:165: log += urlCanonicalized;
On 2016/09/07 16:50:52, Eric wrote:
> It would be better here to use the argument `url` unmodified so that the log
> contains what came in from the outside.

During debugging I actually find it more convenient to have the processed URL
here. Just to see what exactly is being compared to what.

https://codereview.adblockplus.org/29351560/diff/29351566/src/shared/Utils.cpp
File src/shared/Utils.cpp (right):

https://codereview.adblockplus.org/29351560/diff/29351566/src/shared/Utils.cp...
src/shared/Utils.cpp:212: urlCanonicalized.resize(url.length() * 2);
On 2016/09/07 16:50:53, Eric wrote:
> Canonicalization can add escape sequences, so sizing the byte buffer based
only
> on the input string can/will lead to buffer overflows.

Done.

https://codereview.adblockplus.org/29351560/diff/29351566/src/shared/Utils.cp...
src/shared/Utils.cpp:214: UrlCanonicalizeW(url.c_str(), &urlCanonicalized[0],
&urlSize, 0);
On 2016/09/07 16:50:53, Eric wrote:
> You can call this function with argument 'dwFlags' = URL_UNESCAPE to collapse
> the substring "%20" to " ". (As well as any other unsafe URL characters that
are
> legal in path names.)
> 
> That should be sufficient to create a canonical URL for comparison.
> 
> Or we can just use the old function.

Done.

https://codereview.adblockplus.org/29351560/diff/29351566/src/shared/Utils.cp...
src/shared/Utils.cpp:214: UrlCanonicalizeW(url.c_str(), &urlCanonicalized[0],
&urlSize, 0);
On 2016/09/07 16:50:53, Eric wrote:
> Need to verify the return value here, just in case.

Done.

https://codereview.adblockplus.org/29351560/diff/29351566/src/shared/Utils.cp...
src/shared/Utils.cpp:219: std::wstring EscapeUrl(const std::wstring& url)
On 2016/09/07 16:50:53, Eric wrote:
> If we don't compare using escaped URL forms, we don't need this function at
all.

Done.

Powered by Google App Engine
This is Rietveld