Giter Site home page Giter Site logo

Comments (6)

github-actions avatar github-actions commented on August 17, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

from powertoys.

xieve avatar xieve commented on August 17, 2024

Huh. The bot was better at searching than me. Duplicate of #31322.

from powertoys.

xieve avatar xieve commented on August 17, 2024

Reopening as a general-scope issue about being limited to two specific URI schemes. I don't see why PT Run should be hard-codedly limited to only steam and epic games URL shortcuts. This should at the very least be configurable.

cf.

private static readonly Regex InternetShortcutURLPrefixes = new Regex(@"^steam:\/\/(rungameid|run|open)\/|^com\.epicgames\.launcher:\/\/apps\/", RegexOptions.Compiled);
// This function filters Internet Shortcut programs
private static Win32Program InternetShortcutProgram(string path)
{
try
{
// We don't want to read the whole file if we don't need to
var lines = FileWrapper.ReadLines(path);
string iconPath = string.Empty;
string urlPath = string.Empty;
bool validApp = false;
const string urlPrefix = "URL=";
const string iconFilePrefix = "IconFile=";
foreach (string line in lines)
{
// Using OrdinalIgnoreCase since this is used internally
if (line.StartsWith(urlPrefix, StringComparison.OrdinalIgnoreCase))
{
urlPath = line.Substring(urlPrefix.Length);
if (!Uri.TryCreate(urlPath, UriKind.RelativeOrAbsolute, out Uri _))
{
ProgramLogger.Warn("url could not be parsed", null, MethodBase.GetCurrentMethod().DeclaringType, urlPath);
return InvalidProgram;
}
// To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname
if (InternetShortcutURLPrefixes.Match(urlPath).Success)
{
validApp = true;
}
}
else if (line.StartsWith(iconFilePrefix, StringComparison.OrdinalIgnoreCase))
{
iconPath = line.Substring(iconFilePrefix.Length);
}
// If we resolved an urlPath & and an iconPath quit reading the file
if (!string.IsNullOrEmpty(urlPath) && !string.IsNullOrEmpty(iconPath))
{
break;
}
}
if (!validApp)
{
return InvalidProgram;
}
try
{
return new Win32Program
{
Name = Path.GetFileNameWithoutExtension(path),
ExecutableName = Path.GetFileName(path),
IcoPath = iconPath,
FullPath = urlPath,
UniqueIdentifier = path,
ParentDirectory = Directory.GetParent(path).FullName,
Valid = true,
Enabled = true,
AppType = ApplicationType.InternetShortcutApplication,
};
}
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
{
ProgramLogger.Warn($"|Permission denied when trying to load the program from {path}", e, MethodBase.GetCurrentMethod().DeclaringType, path);
return InvalidProgram;
}
}
catch (Exception e)
{
ProgramLogger.Exception($"|An unexpected error occurred in the calling method InternetShortcutProgram at {path}", e, MethodBase.GetCurrentMethod().DeclaringType, path);
return InvalidProgram;
}
}

from powertoys.

Aaron-Junker avatar Aaron-Junker commented on August 17, 2024

@htcfreek, do you know why it is limited only to these two protocols?

from powertoys.

htcfreek avatar htcfreek commented on August 17, 2024

This eas not explicitly forced. It is by design. We need to decide if it is an application/webpage or not. So we only accept specific shortcuts which is currently apps, webpages and steam.

So we need an enhancement for the plugin code to support/allow these shortcuts.

from powertoys.

xieve avatar xieve commented on August 17, 2024

This eas not explicitly forced. It is by design. We need to decide if it is an application/webpage or not. So we only accept specific shortcuts which is currently apps, webpages and steam.

So we need an enhancement for the plugin code to support/allow these shortcuts.

  1. Webpages are not allowed. I have a lot of .url shortcuts to webpages, none of which show up as programs. This is only logical, since https:// shortcuts are not among the two filtered types in the code snippet I linked above.
  2. What other types of .url shortcuts are there that would not be desirable to index? I can't think of any.

My rationale is as follows:

  • If there is a shortcut in the Start Menu, it is intended to be handled like a program.
  • This applies especially to any custom URI scheme that is not https://, file:// or similar.
  • The Windows Start Menu itself does not differentiate between types of shortcuts at all. For example, here is that same .url shortcut I created in the process documented above, appearing in the Windows Start Menu search.

image

In my opinion, PT Run should never display less local results than the Start Menu in the default configuration.

Reading up on the history of the filter, URL shortcuts were added to support Steam and Epic Games games specifically. I believe this support should be broadened, and the filter removed or made configurable.

from powertoys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.