cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

URL parameter array

Jump to solution

Hello, I came across an interesting problem. I am trying to save file IDs from a URL similar to the one below:
https://xyz.com/index.php?fileIDs[]=123&fileIDs[]=456&Idontneedit=true&Idontneeditneither=true

I need to save only the "fileIDs[]" values in Persistent Data Storage for further reference. I do not want to save any other parameters. How to do it?

From what I noticed there are two options (neither solves the issue completely):

1. the OS 8.2.2 allows the use PDStorage.AddUserData.String and match the URL.GetParameter(String) which will save the value of first "fileIDs[]" parameter;

2. the OS 8.2.2 allows the use of PDStorage.AddUserData.List.String and match URL.Parameters but this way I will save all the parameters.

Is there support for URL parameter arrays in newer McAfee web gateway OS versions. If so, could you recommend the most stable one?

I will really appreciate suggestions.

2 Solutions

Accepted Solutions
asabban
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 2 of 4

Re: URL parameter array

Jump to solution

Hi,

we do not have an option to get all parameters of the same type, as you outline. URL.ParameterString will give you all parameters as a string. URL.GetParameter will only give the first parameter.

What I would do:

Get a user-defined property of type List of String. Then set this user-defined property to List.OfString.Sort(URL.Parameters). By doing so you can ensure that all the parameters are ordered one by another.

As a next step use List.OfString.ToString to convert the list into a string, such as

fileIDs[]=123; fileIDs[]=456; Idontneedit=true; Idontneeditneither=true

Use the string operations we have to remove everything in front of the first fileIDs and everything after the last fileIDs, so you end up with a string like

fileIDs[]=123; fileIDs[]=456

From here you can convert back to a list (String.ToStringList) and store the result as a list in PD Storage.

Unfortunately there is no easier way as far as I know.

Andre

View solution in original post

fw_mon
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 4 of 4

Re: URL parameter array

Jump to solution

Hello @User43047177

 here is an (ugly) solution:

 

Name:
get params

Comment:

Rule Criteria:
Cycle.Name equals "Request"

Action:
Continue

Events:
Set User-Defined.list = String.ToStringList (String.ReplaceAllMatches (URL.ParametersString, regex((?!fileIDs\[\]=\d+)([^\d]+)), ",\2"), ",", "")

I haven't tested it with all possible combinations of parameters but it should work for your case.

The asabban's solution looks more robust for me though

View solution in original post

3 Replies
asabban
McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 2 of 4

Re: URL parameter array

Jump to solution

Hi,

we do not have an option to get all parameters of the same type, as you outline. URL.ParameterString will give you all parameters as a string. URL.GetParameter will only give the first parameter.

What I would do:

Get a user-defined property of type List of String. Then set this user-defined property to List.OfString.Sort(URL.Parameters). By doing so you can ensure that all the parameters are ordered one by another.

As a next step use List.OfString.ToString to convert the list into a string, such as

fileIDs[]=123; fileIDs[]=456; Idontneedit=true; Idontneeditneither=true

Use the string operations we have to remove everything in front of the first fileIDs and everything after the last fileIDs, so you end up with a string like

fileIDs[]=123; fileIDs[]=456

From here you can convert back to a list (String.ToStringList) and store the result as a list in PD Storage.

Unfortunately there is no easier way as far as I know.

Andre

View solution in original post

Re: URL parameter array

Jump to solution
Thank you very much!
fw_mon
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 4 of 4

Re: URL parameter array

Jump to solution

Hello @User43047177

 here is an (ugly) solution:

 

Name:
get params

Comment:

Rule Criteria:
Cycle.Name equals "Request"

Action:
Continue

Events:
Set User-Defined.list = String.ToStringList (String.ReplaceAllMatches (URL.ParametersString, regex((?!fileIDs\[\]=\d+)([^\d]+)), ",\2"), ",", "")

I haven't tested it with all possible combinations of parameters but it should work for your case.

The asabban's solution looks more robust for me though

View solution in original post

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community