Closed Bug 502486 Opened 15 years ago Closed 15 years ago

Don't strip the www off urls for the block-image context menu label

Categories

(Firefox :: Menus, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3.7a1

People

(Reporter: Natch, Assigned: Natch)

References

()

Details

Attachments

(1 file, 1 obsolete file)

From bug 417545 comment 91:

> The way nsPermissionManager handles entries is a bit complicated (although 
> not necessarily wrong). Any uri passed to it will get stored by host, as is. 
> Then when TestPermission is called, it will check the hash table for that 
> host and all of its' super-domains. In practice this means that 
> "http://www.google.com" won't match either "http://google.com" or 
> "http://images.google.com". However, "http://google.com" will match any 
> sub-domain of google.com, including "http://www.google.com" and 
> "http://images.google.com".

> The only thing wrong with that approach (and this probably belongs in a
> separate bug, which I'll file shortly) is that it doesn't cut off "www" which
> is not a sub-domain, rather a standard prefix. The intention is that the
> caller should be able to chose up to which sub-domain it wants to add the 
> permission for, and "www" shouldn't be considered a sub-domain in that case.

Bug filed.
Flags: wanted1.9.2?
Dan, can you offer any opinion here?

Gavin, nsContextMenu currently cuts off the www afaict to show in the context menu incorrectly, should this be fixed or should we just wait for a fix here?
I don't really think we should do something like this in the backend - nsPermissionManager should provide a simple service of looking up a host and coming back with an answer. It shouldn't get into the business of guessing what the consumer wanted to do.

This is best handled in the front-end that deals with nsPermissionManager - i.e. in the Firefox code that adds the host in the first place. Do we not already have a regex in there somewhere to strip stuff off?
I was thinking the same thing originally, but then I thought if TestPermission does walk up the domains in the url already, then that means the permission manager is already dealing with domains, not plain input. As such I figured that to the permission manager's implementation www.google.com and google.com are really the same thing.

The browser code incorrectly uses the regex for the label, not when actually passing in the url, which is why if www.google.com is blocked, google.com won't be.
(In reply to comment #3)
> I was thinking the same thing originally, but then I thought if TestPermission
> does walk up the domains in the url already, then that means the permission
> manager is already dealing with domains, not plain input. As such I figured
> that to the permission manager's implementation www.google.com and google.com
> are really the same thing.

To a browser, perhaps. nsPermissionManager is entirely unrelated to browsing, however... it's just a database of hosts that knows about the concept of subdomains.

Parsing out the host from a URI is trivially done with nsIURI, after which regexing off subdomains from |uri.host| is simple enough.
Ok, in that case I'll morph this into a browser bug and actually strip off the 'www'.
Assignee: nobody → highmind63
Component: Preferences: Backend → Menus
Flags: wanted1.9.2?
Product: Core → Firefox
QA Contact: prefs → menus
Summary: nsPermissionManager::Add should strip off the www in urls → Strip off the www in the host when blocklisting images
Gavin told me on irc to just change the label...
Status: NEW → ASSIGNED
Summary: Strip off the www in the host when blocklisting images → Don't strip the www off urls for the block-image context menu label
Attached patch label change (obsolete) — Splinter Review
Attachment #387366 - Flags: review?(gavin.sharp)
FTR, this was added in Firebird by one norrity. Obviously, as was the custom then, there's no bug or reason quoted...

Putting the cvs diff url in the url field for the curious...
Gavin: can you review this please, this patch is per your suggestion (I think).
Whiteboard: [needs review gavin]
Comment on attachment 387366 [details] [diff] [review]
label change

Come to think of it, maybe it's just better to keep the www as it doesn't really mean anything significant to the average user and adds clutter.

Alex, what are your thoughts?
Attachment #387366 - Flags: ui-review?(faaborg)
From my quick reading of the previous comments it seems like stripping the www off helps both advanced users (since it is a more accurate representation of what will actually be blocked), as well as novice users (who don't really understand sub domain structures to begin with).
Attachment #387366 - Flags: ui-review?(faaborg) → ui-review-
Comment on attachment 387366 [details] [diff] [review]
label change

I'm pretty sure I'm in favor of removing the www, as long as this matches the actual behavior correctly (so blocking images from a.site.com will also block images from b.site.com, and we should just list site.com)
Well, not exactly, the *actual* behavior is a bit different. In the specific case you mentioned, a.site.com won't be stripped down to site.com in the label. It's only www.site.com which gets stripped, which makes this entirely wrong, as www.site.com won't match site.com or a.site.com, only www.site.com.

The only reason I suggested not removing the www is because it _doesn't_ match the actual implementation (i.e. what actually happens).

For a more in-depth explanation see bug 417545 comment 91, which is what triggered this bug.
Attachment #387366 - Flags: ui-review- → ui-review+
Comment on attachment 387366 [details] [diff] [review]
label change

>The only reason I suggested not removing the www is because it _doesn't_ match
>the actual implementation (i.e. what actually happens).

Ok, thanks for the clarification.  One way to try to make this more clear might be to add entries for both www.site.com and site.com to the exceptions window (and the user could later manager them separately, like choose to delete one).

In the meantime keeping the www sounds fine for the reasons you outlined.
>One way to try to make this more clear might
>be to add entries for both www.site.com and site.com to the exceptions window
>(and the user could later manager them separately, like choose to delete one).

To clarify, I meant if we decided to expand the blocking for the specific case of www.site.com to the full domain, this might make more sense in the exceptions window.
It's possible now to add whatever you want in the exceptions window, i.e. if you don't want to see any images at all from google you'd type in google.com in the input line and block that which will automatically block all images from any *.google.com site.

This is about the default accessible image-blocking menu entry you get in the image context-menu, which is probably the only substantial ui exposure this feature gets.
OS: Windows Vista → All
Hardware: x86 → All
Comment on attachment 387366 [details] [diff] [review]
label change

Dao, can you review this? It's a tiny code removal that updates the context menu label to reality.
Attachment #387366 - Flags: review?(gavin.sharp) → review?(dao)
Whiteboard: [needs review gavin] → [needs review dao]
Comment on attachment 387366 [details] [diff] [review]
label change

var hostLabel; needs to be moved up a level to make it clear that it's used outside of the 'if' block.
Attachment #387366 - Flags: review?(dao) → review+
Whiteboard: [needs review dao]
Attachment #387366 - Attachment is obsolete: true
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/6874bc893f09
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3.7a1
Can we get a test for this change?
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: