PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[Hosts File Editor] Examples in hosts file treated as real entries.

Open htcfreek opened this issue 1 year ago • 7 comments

Microsoft PowerToys version

0.1.0 (pre-built of 0.64.0)

Running as admin

  • [ ] Yes

Area(s) with issue?

General

Steps to reproduce

  1. Open Hots File Editor.

✔️ Expected Behavior

See no entries because I don't have set some.

❌ Actual Behavior

Seeing the default examples as real entries.

image

Other Software

No response


cc: @davidegiacometti

htcfreek avatar Oct 15 '22 09:10 htcfreek

I am tempted to close this as not a bug. I don't want to add exclusion for certain entries and these are valid disabled entries. The user can delete these entries and have full control of invalid lines from the PT. @crutkas any thoughts?

davidegiacometti avatar Oct 15 '22 11:10 davidegiacometti

Maybe directly call these out as known examples? I see both sides

crutkas avatar Oct 15 '22 16:10 crutkas

  1. We can threat these two specific entries as invalid lines since they are well known example from the Windows header. But I wouldn't do the same with localhost entries.

    • 102.54.94.97 rhino.acme.com # source server
    • 38.25.63.10 x.acme.com # x client host
  2. Another solution could be a teaching tooltip that explain to the user that 102.54.94.97 and 38.25.63.10 are two sample entries from the file header and can be deleted.

https://learn.microsoft.com/en-us/windows/apps/design/controls/dialogs-and-flyouts/teaching-tip

Anyway, is this needed for 0.64 or can wait for user feedbacks post utility release?

davidegiacometti avatar Oct 16 '22 16:10 davidegiacometti

I don't this is needed for the 0.64.0 release. Let's wait for user feedback.

htcfreek avatar Oct 16 '22 16:10 htcfreek

Well, I came here looking for an explanation of those acme severs in this new GUI app I was testing out of curiousity.

I agree with the OP, but I see the point of the developers since the hosts file is:

#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

From my point of view, very few advanced users are going to use this new GUI app instead of editing a plain text file. I would take into serious consideration what the OP said, because those fake entries, listed without the context provided by the comments preceding them ("For example... "), are quite misleading. You might use a special syntax for entries created and enabled/disabled via the app.

thistlillo avatar Feb 17 '23 05:02 thistlillo

I feel like if we detect the acme ones, we should 'smart delete' them or at a minimum, not show them as something that can be enabled

crutkas avatar Feb 22 '23 21:02 crutkas

My position is that comment lines are comment lines and, according to the one specification (https://man7.org/linux/man-pages/man5/hosts.5.html): "Text from a "#" character until the end of the line is a comment, and is ignored." So my feeling is that they should be ignored by the Hosts File Editor too. If it displays all lines that match as it does now then that creates confusion with lines that might exist like:

# Change example .com on 2023-05-26 to: 123.123.123.123 example.com

The point is that the comment is not to disable an entry but to record it being changed. Making an exception or special case for the acme examples doesn't solve the general issue. An alternative possibility might be to just display all of the comment lines so that the 'real' entries are visible in context.

Just my three ha'pence.

Fjeldfross avatar May 26 '23 02:05 Fjeldfross

they are well known example from the Windows header.

Wanted to chime in here to share that this was not well known to me. In the UI there is no way to clearly see what is example and what is not. My two cents is that it would be worth having a setting to either hide examples, or to clearly mark them as such.

What might be obvious to some will likely not be to many others :)

m0xsec avatar Jun 25 '23 00:06 m0xsec

I agree that they should at least be clearly marked as examples in some way; I was immediatelly worried something fishy was going on when I saw them, since I don't usually fiddle with hosts, until I finally figured it out.

MightyFlix avatar Aug 12 '23 19:08 MightyFlix

Also just got here wondering why these lines were in my new PowerToys release. I know the guy who runs acme.com, so it was a little alarming.

Weird problem; the real question is why those entries are in Windows' default setup. Presumably inherited from some other thing years ago. It wouldn't be the worst idea for PowerToys to recognize specifically the Windows default lines and ignore them, although that will create confusion for someone else someday maybe.

NelsonMinar avatar Aug 24 '23 14:08 NelsonMinar

Shouldn't this be as simple as "Comments should not be interpreted as actual data" anyways?

Jay-o-Way avatar Aug 29 '23 08:08 Jay-o-Way

Shouldn't this be as simple as "Comments should not be interpreted as actual data" anyways?

No because a comment sign is also used to disable entries.

htcfreek avatar Aug 29 '23 09:08 htcfreek

This is horrible default functionality and gave me a scare that I had malware, because I've never seen acme.com before in my life.

Comments are visible to humans for a reason. This app should show comments, interleaved with each entry in their normal sequential order. Disabling code by commenting is a hack, a convenience, and it always has been. Maintain a disabled-hosts file next to the hosts file or something and explain which program is responsible for that file in comments inside the file. At the very least, anything you programmatically disable by turning into a comment should specify which program did it. Many programs might edit a hosts file.

twome avatar Sep 22 '23 05:09 twome

This has been worked on for the 0.74.0 release. Please update PowerToys to the latest version. 😉 https://github.com/microsoft/PowerToys/releases

jaimecbernardo avatar Sep 28 '23 10:09 jaimecbernardo