How to solve this error"Malformed URL"? - extjs

I want to pass a params string include style Tag like example:
a:"<font color=blue>testing!##$%^&*()_+{}|:"<>?-=[]\;',./"
i am using decodeURI to pass the string.but still got error in extjs.
I has been checked,is a symbol % cause this error come out.
How to solve it??

Not sure that I understand your question completely, but you should probably start by escaping your string to prevent the second " from terminating your string.
// Original:
a:"<font color=blue>testing!##$%^&*()_+{}|:"<>?-=[]\;',./"
You can tell by the syntax highlighting that the original string is terminated premature.
// Escaped:
a:"<font color=blue>testing!##$%^&*()_+{}|:\"<>?-=[]\\;',./"
By using the escape character \ you can tell JS to interpret the second " as part of the string, and not a string terminator. You should also escape the \ character near the end of your string to prevent JS thinking you are using it to escape the ; character.

1)Ext.getCmp('txt').setValue(Ext.util.Format.htmlDecode(getSel.data.Message));
use Ext.util.Format.htmlDecode
2nd part is
params: {
msg: (Ext.getCmp('txt').getValue())
no need to encode
3)
Page Language="C#" AutoEventWireup="true" CodeBehind="Msg.aspx.cs" Inherits="Msg" ValidateRequest="false" %>
open Msg.aspx
add in ValidateRequest="false"

Related

VBSCRIPT REPLACE not removing spaces from Decrypted fields

Got quite a head-scratcher....
I'm using the VBScript function REPLACE to replace spaces in a decrypted field from a MSSQL DB with "/".
But the REPLACE function isn't "seeing" the spaces.
For example, if I run any one of the following, where the decrypted value of the field "ITF_U_ClientName_Denc" is "Johnny Carson":
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/")
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/")
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"),"Chr(160)","/")
REPLACE(CSTR(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"))," ","/")
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/",1,-1,1)
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/",1,-1,0)
The returned value is "Johnny Carson" (space not replaced with /)
The issue seems to be exclusively with spaces, because when I run this:
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"),"a","/")
I get "Johnny C/rson".
Also, the issue seems to be exclusively with spaces in the decrypted value, because when I run this:
REPLACE("Johnny Carson"," ","/")
Of course, the returned value is "Johnny/Carson".
I have checked what is being written to the source of the page and it is simply "Johnny Carson" with no encoding or special characters.
I have also tried the SPLIT function to see if it would "see" the space, but it doesn't.
Finally, thanks to a helpful comment, I tried VBS REGEX searching for \s.
Set regExp = New RegExp
regExp.IgnoreCase = True
regExp.Global = True
regExp.Pattern = "\s" 'Add here every character you don't consider as special character
strProcessed = regExp.Replace(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"), "?")
Unfortunately, strProcessed retruns "Johnny Carson" (ie. spaces not detected/removed).
If I replace regExp.Pattern = "a", strProcessed returns "Johnny C?rson".
Many thanks for your help!!
As we found, the right character code is 160, and that did the trick:
replace(..., ChrW(160), "...")
This seems to be data specific and, additionally, as an alternative you can try to get same encoding of the source script (i.e. save with Save As with Encoding), or convert received database value into a different target encoding.

Escaping parentheses in string. Contains in apex

I was trying to do some basic check using salesforce string object methods
Below is the sample code I'm trying to execute.
String myStr = 'Hello (AB)';
if(myString.contains('(AB)') {
... Do stuff
}
I want to look for string starting with "(" and ending with ")".
I tried putting '\(', '\\(' but nothing seems to work.
Thanks in advance!
Hi use can try the following code
String s1 = '(Yellow)';
if(String.isNotBlank(s1.substringBetween('(',')'))){
System.debug('s1'+s1);
}

How to remove Double Quote in JSON Array

I searched through this forum but did not get similar case of removing double quotes in JSON array.
This is my part request format
"customer_address_list":[{"email_address" :{"email_to" : ""},
"method" : "EMAIL",
"customer_id" : ""}]
As this is dynamic values I putting values with push of JSON in for loop. Something like this in my js
Request_Format.customer_address_list.push( XXXXXXXXXXX) ;
Every time there is unwanted double quotes appending in every entry like
"customer_address_list":[
"{"email_address":"email_to":"xyz.pqqr#companyname.com"},"method":"EMAIL","customer_id":"1"}",
"{"email_address":"email_to":"zzz.aaaa#companyname.com"},"method":"EMAIL","customer_id":"2"}",
"{email_address":"email_to":"www.aaaa#companyame.com"},"method":"EMAIL","customer_id":"3"}"]
Due to this additional double quote at start and end of every entry, Final JSON became invalid.
All above code shared is in java script
Is there any work around to remove this double quotes
Thanks in advance
If you are using Python, you can convert each string to a dictionary literal using the eval function
customer_as_dict = eval(customer_as_string)
To remove the quotes around the name customer_address_list, you may be able to use
eval("customer_address_list") = [eval(customer_as_string) for customer_as_string in dict_as_string]

Encode HTML Characters in C

I am reading data over a socket and parsing it with LibXML.
The problem that I am currently having is that sometimes there is a web link in the data which breaks the parser.
http://example.com/?key=value&key2=value
Is there any way to convert that to html characters?
Something like the above to
http://example.com/?key=value&key2=value
Example of socket data:
<node link="http://example.com/?key=value&key2=value" />
EDIT:
Found a solution that works for my problem here
You are going to have to do a pre-filter here. Contrary to other indications, search and replace just won't cut it. Consider your search side is &, which matches too much.
Construct the following finite state machine:
NORMAL:
if next matches "<" then TAG
TAG:
if next matches "![CDATA[" then CDATA
TAGSCAN
TAGSCAN:
if next matches whitespace then TAGSCAN2
if next matches > or next matches /> then NORMAL
TAGSCAN2:
if next matches whitespace then TAGSCAN2
if next matches SRC= or next matches HREF= then URL
TAGSCAN
URL:
we found an attribute with a URL in it. Do your search and replace
on the contents of the URL attribute value, advance past the URL and
go back to TAGSCAN
CDATA:
if next doesn't match ]]> then CDATA
NORMAL
I have found a nice solution using the code from
Find and Replace that uses a Find and Replace method suggested by bolov.
retval = str_replace(message, size, "&", "&");
if (!retval) {
printf("Not enough room to replace & with `&'\n");
}

Crystal Report issue.Net 4.0

There is a definite syntax of passing value to crystal-report Formula Field from .Net 4.0- Code
behind
E.g. (C# Code):
Following will NOT work
_rpt.DataDefinition.FormulaFields["fClient"].Text = Mr.Gates;
Following will work-
_rpt.DataDefinition.FormulaFields["fClient"].Text = "\"Mr.Gates\"";
I haven't understand the prominence and way of using following ..
"\" \""
What if "Mr. Gates:" is in some variable, I want to pass!?
plz reply with some code...
Thanks
\" sends a literal " through to the variable. For literal string values in Formulae to be seen as literal strings they must be quoted hence sending the quoted " through is necessary.

Resources