rome Posted April 1, 2013 Report Share Posted April 1, 2013 Sometimes I get all sorts of ascii characters, (e.g. &), and I want to replace them with the original form (e.g. &). After searching the web for a bit, I didn't stumble upon anything... Have you had any experience and could share a snippet? Link to comment Share on other sites More sharing options...
necrox Posted April 1, 2013 Report Share Posted April 1, 2013 You can use the function urldecode to replace encoded characters like & in URLs. Link to comment Share on other sites More sharing options...
rome Posted April 1, 2013 Author Report Share Posted April 1, 2013 I actually tried that. It didn't work O_o Link to comment Share on other sites More sharing options...
necrox Posted April 1, 2013 Report Share Posted April 1, 2013 Works fine for me. Try using it this way for decoding the variable containing encoded character strings: {yourvariable:urldecode} Link to comment Share on other sites More sharing options...
rome Posted April 1, 2013 Author Report Share Posted April 1, 2013 Tried again. And nope. Doesn't work for me. It's not a url I'm trying to get, so maybe that's the problem. I'm trying to decode the app description that sometimes add ascii codes. I tried to create a new variable and give it the {variable:urldecode} but it didn't work... Link to comment Share on other sites More sharing options...
shawn Posted April 1, 2013 Report Share Posted April 1, 2013 Can you provide an example of your app profile so we can investigate? Link to comment Share on other sites More sharing options...
rome Posted April 5, 2013 Author Report Share Posted April 5, 2013 This is a template of portableApps I modified from the templates forum. I'm trying to decode what's in the UserNotes tag. <?xml version='1.0' encoding='utf-8'?> <Jobs> <ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Guid="35049824-00be-4a7b-951a-50dc65b13111"> <Name> <placeholder name="Name of application" variable="appName:regexreplace:([\s\t\r\n\\&\/]+):" /> </Name> <Category> <placeholder name="Category" options="{categories}" /> </Category> <CanBeShared>false</CanBeShared> <CheckForUpdatesOnly>false</CheckForUpdatesOnly> <DeletePreviousFile>true</DeletePreviousFile> <DownloadBeta>Default</DownloadBeta> <Enabled>true</Enabled> <ExclusiveDownload>false</ExclusiveDownload> <FileHippoId /> <FixedDownloadUrl>{dlUrl:urldecode}</FixedDownloadUrl> <HttpReferer>{dlRedirect:urldecode}</HttpReferer> <IgnoreFileInformation>false</IgnoreFileInformation> <PreviousLocation /> <ShareApplication>false</ShareApplication> <SourceType>FixedUrl</SourceType> <TargetPath>{dlPath}</TargetPath> <UserAgent>{sfua}</UserAgent> <UserNotes> <placeholder name="Application description" variable="appDescription:urldecode"/> </UserNotes> <VariableChangeIndicator>appVersion</VariableChangeIndicator> <WebsiteUrl>{appWebsite}</WebsiteUrl> <Variables> <item> <key> <string>appDescription</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>RegularExpression</VariableType> <Regex>(?<=tagline.*?<p>)(.*?)(?=</p)</Regex> <Url>{dlPage}</Url> <Name>appDescription</Name> </UrlVariable> </value> </item> <item> <key> <string>appName</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>RegularExpression</VariableType> <Regex><title>(.*?)(?=\s.+Portable)</Regex> <Url>{dlPage}</Url> <Name>appName</Name> </UrlVariable> </value> </item> <item> <key> <string>appSource</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>Textual</VariableType> <TextualContent>PortableApps</TextualContent> <Name>appSource</Name> </UrlVariable> </value> </item> <item> <key> <string>appType</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>Textual</VariableType> <TextualContent>Portable</TextualContent> <Name>appType</Name> </UrlVariable> </value> </item> <item> <key> <string>appUpFreq</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>Textual</VariableType> <TextualContent> <placeholder name="Application description" value="" options="Urgent|Monthly|Never" /> </TextualContent> <Name>appUpFreq</Name> </UrlVariable> </value> </item> <item> <key> <string>appVersion</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>RegularExpression</VariableType> <Regex>(?<=Portable_.*?)[0-9.]{2,}(?=\.paf)</Regex> <Url>{dlPage}</Url> <Name>appVersion</Name> </UrlVariable> </value> </item> <item> <key> <string>appWebsite</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>RegularExpression</VariableType> <Regex>href="([^\s]*)" learn more</Regex> <Url>{dlPage}</Url> <Name>appWebsite</Name> </UrlVariable> </value> </item> <item> <key> <string>dlPath</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>Textual</VariableType> <TextualContent>{startuppath}..\{appname}-{appVersion}.{dlUrl:ext}</TextualContent> <Name>dlPath</Name> </UrlVariable> </value> </item> <item> <key> <string>dlPage</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>Textual</VariableType> <TextualContent> <placeholder name="Application Page URL"/> </TextualContent> <Name>dlPage</Name> </UrlVariable> </value> </item> <item> <key> <string>dlRedirect</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>Textual</VariableType> <TextualContent>http://portableapps.com/bouncer?t=</TextualContent> <Name>dlRedirect</Name> </UrlVariable> </value> </item> <item> <key> <string>dlUrl</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>RegularExpression</VariableType> <Regex>[^"'=]+(?>\.exe)</Regex> <Url>{dlPage}</Url> <Name>dlUrl</Name> </UrlVariable> </value> </item> <item> <key> <string>installPath</string> </key> <value> <UrlVariable> <RegexRightToLeft>false</RegexRightToLeft> <VariableType>Textual</VariableType> <TextualContent>{startuppath}..\{appname}</TextualContent> <Name>installPath</Name> </UrlVariable> </value> </item> </Variables> <SetupInstructions> <SetupInstruction xsi:type="CustomSetupInstruction"> <Code> {ahk} "{ahk-paf}" "{file}" "{installPath}" ::Creating and renaming a custom .ini to disable splash screen if exist "{installPath}\*Portable.ini" exit for /f "tokens=*" %a in ('dir /b "{installPath}\Other\Source\*Portable.ini"') do ( set ini={installPath}\Other\Source\%a set file=%a ) For /f "tokens=*" %i in ('type "%ini%"') do if /I "%i" EQU "DisableSplashScreen=false" (echo DisableSplashScreen=true>>"{installPath}\%file%") else (echo %i>>"{installPath}\%file%") for /f "tokens=*" %a in ('dir /b "{installPath}\*.exe"') do set exe=%~na if exist "{installPath}\*Portable.ini" rename "{installPath}\%file%" "%exe%.ini" ::Creating and renaming a custom .ini to disable splash screen del "{file}" /s /q </Code> <Type>Batch</Type> </SetupInstruction> </SetupInstructions> <ExecuteCommand> /*This is a comment line, the line below is the C# script. It will run the instructions found in the Setup Tab. If the command below is encapsulated with stars and slashes merely remove them to make the command function, otherwise it will remain a comment*/ app.Install(null); </ExecuteCommand> <ExecutePreCommand> if "{dlPath}" EQU "" START CMD /C "ECHO {appname}: Unable to find download, investigate & PAUSE & exit& if "{FixedDownloadUrl}" EQU "" if "{FileHippoId}" EQU "" START CMD /C "ECHO {appname}: Unable to find download, investigate & PAUSE & exit& </ExecutePreCommand> <ExecuteCommandType>CS</ExecuteCommandType> </ApplicationJob> </Jobs> Also, there was a case that I needed to urlencode a url - it had spaces, and I wanted them to be %20. The encode, however, made spaces into '+'... Link to comment Share on other sites More sharing options...
shawn Posted April 5, 2013 Report Share Posted April 5, 2013 Assuming I understand what you're after, this: <UserNotes> <placeholder name="Application description" variable="appDescription:urldecode"/> </UserNotes> Should be this: <UserNotes>{appDescription:urldecode}</UserNotes> URLencoding is tricky. The most common requirement for URLencoding is to convert querystrings into usable data, and querystrings (the part after the "?" in a URL) convert a space to a +. While some servers support it, spaces in the path portion of a URL are actually forbidden in the RFC - of course, that never stopped anyone. If you have complete control over the url, you could do something like this instead: {myurl1:replace: :%20} Link to comment Share on other sites More sharing options...
rome Posted April 5, 2013 Author Report Share Posted April 5, 2013 Yep, that's what I ended up doing. Still weird. About the description - that somewhat beats the purpose of having a description of the file in the information tab, and I don't want to create another variable just for that, but I guess that would do. Thanks. Link to comment Share on other sites More sharing options...
shawn Posted April 6, 2013 Report Share Posted April 6, 2013 So then you're not trying to create the notes based on a variable, but on input in the profile creation? Then I'd use this: <UserNotes> <placeholder name="Application description" value="" /> </UserNotes> It won't assign it to a 'variable' but it will be populated in the information tab. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now