In my Laravel 8 / blade/ jQuery 3.5.1 app I need to put string text in javascript like :
L.marker([{{$adLocation->lat}}, {{ $adLocation->lng }}]).addTo(locationMap)
.bindPopup("<b>Add Location!</b><br />"+'{!! crlf($adLocation->content) !!}'+".").openPopup();
I try to replace crlf characters with method like
function crlf(string $s) : string
{
return str_replace( array("\r\n", "\r", "\n"), "<br />", $s);
// 2 lines below does not work too
// return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $s);
// return nl2br($s);
}
But anyway I got error :
edit:539 Uncaught SyntaxError: Invalid or unexpected token
and I see in browser : https://prnt.sc/wtpnri and https://prnt.sc/wtq78t
Which way is valid ?
Thanks!
Related
Found in [consoletvs\charts\src\ChartsServiceProvider.php]
Error
Found this error.. any ideas ?
The error is very clear, it tells you that you are missing one ) after your $app variable.
Try this :
public function register(): void {
$this->app->singleton(Registrar::class, fn(Application $app)) => new Registrar (
//...
);
}
version info:
Server version: Apache Tomcat/9.0.17
Server built: Mar 13 2019 15:55:27 UTC
Server number: 9.0.17.0
OS Name: Windows 8.1
OS Version: 6.3
Architecture: amd64
JVM Version: 1.8.0_40-b25
spring-boot-2.1.4
spring-core-5.1.6
I have a html page like this: localhost/example/37%.html
(sorry I can not start url with http// because the edit page will auto-change it to link and will add 25 after %)
when I access this url,I got an error:HTTP Status 400.
It should be, because the % is a escape char.
so I changed the url to: localhost/example/37%25.html.
this time,I got a new error:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Sep 03 09:25:13 CST 2020
There was an unexpected error (type=Internal Server Error, status=500).
URLDecoder: Illegal hex characters in escape (%) pattern - For input string: ".h"
I checked tomcat console,it outputs error message:
2020-09-03 09:25:12 [http-nio-8080-exec-3] ERROR
o.s.b.w.s.support.ErrorPageFilter - Forwarding to error page from request [/37%.html] due to exception [URLDecoder: Illegal hex characters in escape (%) pattern - For input string: ".h"]
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape(%) pattern - For input string: ".h"
at java.net.URLDecoder.decode(URLDecoder.java:194)
at org.springframework.web.servlet.resource.PathResourceResolver.isInvalidEncodedPath(PathResourceResolver.java:285)
at org.springframework.web.servlet.resource.PathResourceResolver.isResourceUnderLocation(PathResourceResolver.java:254)
It seems like tomcat(or browser) has been decode %25 to %,but springboot still to decode % again (PathResourceResolver.java)
I don't know whether this is an bug issue or this is a right way that springboot do not allow % in url
I found something interesting.
now I have two webpages, one named 37%.html,other named 37%25.html
Follow the logic of springboot that it will decode % twice, I accessed this url:
localhost/example/37%2525.html
and it will show me the 37%.html, BUT, it show me the 37%25.html.
so,how many times or how to the springboot decode % ???
then I found two class file in springboot:
ResourceHttpRequestHandler.java
PathResourceResolver.java
they all have a function named: isInvalidEncodedPath()
code is here:
ResourceHttpRequestHandler.isInvalidEncodedPath(path)
private boolean isInvalidEncodedPath(String path) {
if(path.contains("%")) {
try {
String decodedPath = URLDecoder.decode(path, "UTF-8");
if(this.isInvalidPath(decodedPath)) {
return true;
}
decodedPath = this.processPath(decodedPath);
if(this.isInvalidPath(decodedPath)) {
return true;
}
} catch (UnsupportedEncodingException | IllegalArgumentException var3) {
;
}
}
return false;
}
PathResourceResolver.isInvalidEncodedPath(resourcePath)
private boolean isInvalidEncodedPath(String resourcePath) {
if(resourcePath.contains("%")) {
try {
String decodedPath = URLDecoder.decode(resourcePath, "UTF-8");
if(decodedPath.contains("../") || decodedPath.contains("..\\")) {
this.logger.warn("Resolved resource path contains encoded \"../\" or \"..\\\": " + resourcePath);
return true;
}
} catch (UnsupportedEncodingException var3) {
;
}
}
return false;
}
see something different?? they both do URLDecoder.decode(resourcePath, "UTF-8"),but catch different exceptions.
when you access url,springboot will call the funcion at this order:
1 ResourceHttpRequestHandler.isInvalidEncodedPath(path)
2 PathResourceResolver.isInvalidEncodedPath(resourcePath)
so when hit the /37%25.html, in ResourceHttpRequestHandler.isInvalidEncodedPath(path),it gets /37%.html,because tomcat(or browser) decode %25 to %. then URLDecoder.decode("/37%.html", "UTF-8"), trigger IllegalArgumentException, be catched, but do nothing, return false. In PathResourceResolver.isInvalidEncodedPath(resourcePath),URLDecoder.decode("/37%.html", "UTF-8"),trigger IllegalArgumentException, no catced, throw the exception.
when hit the /37%2525.html, in ResourceHttpRequestHandler.isInvalidEncodedPath(path),it gets /37%25.html, URLDecoder.decode("/37%25.html", "UTF-8"),no problem. In PathResourceResolver.isInvalidEncodedPath(resourcePath),URLDecoder.decode("/37%25.html", "UTF-8"),also no problem.then display the 37%25.html
If you just type /37%.html,u will get 400 error, Invalid URI: isHexDigit.
so,unfortunately, the url which has % char, can not be accessed correctly.
Below is the function to receive all incoming calls in my Controller
public function call_incoming()
{
$blocklist = $this->call_log_model->get_blocklist($_REQUEST['From']);
$tenantNum = $this->call_log_model->get_called_tenant($_REQUEST['From']);
$tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_tenant);
$officeStatus = $this->check_office_hours($tenantInfoByNumber->start_office_hours, $tenantInfoByNumber->end_office_hours);
$calldisposition = $this->calldisp_model->get_call_disposition($tenantInfoByNumber->user_id);
$response = new Services_Twilio_Twiml;
if($blocklist == 0)
{
if($officeStatus == "open")
{
if($_POST['Called'] != AGENTPOOL_NUM)
{
$data = array(
'caller'=>$_REQUEST['From'],
'to_tenant'=>$_POST['Called'],
'date_created'=>date('Y-m-d H:i:s')
);
$this->call_log_model->insert_caller_to_tenant($data);
$dial = $response->dial(NULL, array('callerId' => $_REQUEST['From']));
$dial->number(AGENTPOOL_NUM);
print $response;
}
else
{
$gather = $response->gather(array('numDigits' => 1, 'action'=>HTTP_BASE_URL.'agent/call_controls/call_incoming_pressed', 'timeout'=>'5' , 'method'=>'POST'));
$ctr = 1;
foreach($calldisposition as $val )
{
$gather->say('To go to '.$val->disposition_name.', press '.$ctr, array('voice' => 'alice'));
$gather->pause("");
$ctr++;
}
print $response;
}
}
else
{
$response->say('Thank you for calling. Please be advise that our office hours is from '.$tenantInfoByNumber->start_office_hours.' to '.$tenantInfoByNumber->end_office_hours);
$response->hangup();
print $response;
}
}
else
{
$response->say('This number is blocked. Goodbye!');
$response->hangup();
print $response;
}
}
Please advise if I need to post the model...
Here is whats happening everytime an unknown number calls in, the caller will hear an application error has occurred error message and when checking the Twilio console the error it is giving me is
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: agent/Call_controls.php
Line Number: 357
Please be advised that this error only occurs when the caller is a number not in our database yet. When the call comes from a number already saved in our databse, this codes works...
Thank you for the help...
if($tenantNum) {
$tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_tenant);
} else {
$tenantInfoByNumber = ""; // fill this in with relevant fill data
}
This should fix your issue, as there is no TenantNum returned, there is no data, so make it yourself for unknown numbers.
I have an issue with parse + unity in WebGL, it works perfectly in android or pc, but when i test in web this error appears
exception thrown: SyntaxError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'sme 0' is not a valid HTTP header field value.,Error: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'sme 0' is not a valid HTTP header field value.
at Error (native)
at _JS_WebRequest_SetRequestHeader (http://localhost:60265/Release/Web.js:1:299623)
at aAg (http://localhost:60265/Release/Web.js:28:772491)
at YBc (http://localhost:60265/Release/Web.js:23:638406)
at Array.Are (http://localhost:60265/Release/Web.js:24:499286)
at U4p (http://localhost:60265/Release/Web.js:5:760172)
at Z4p (http://localhost:60265/Release/Web.js:5:770191)
at bXo (http://localhost:60265/Release/Web.js:9:582682)
at Array.vWo (http://localhost:60265/Release/Web.js:9:501983)
at Array.dap (http://localhost:60265/Release/Web.js:9:944092)Module.printErr # (index):34Browser.mainLoop.runIter # Web.js:1Browser_mainLoop_runner # Web.js:1
Do you know if this is a bug?
I'm using a personal edition of unity
It was tested in chrome and firefox, in both cases appears an error
EDITED
this code breaks the WebGL game
ParseUser.LogInAsync ("aaaaaa", "bbbbbb").ContinueWith (t => {
if (t.IsFaulted || t.IsCanceled){
ParseUser user = new ParseUser ();
user ["username"] = "aaaaaa";
user ["password"] = "bbbbbb";
ParseUser.LogOutAsync().ContinueWith(c=>{
user.SignUpAsync().ContinueWith(b =>{
if (b.IsFaulted || b.IsCanceled){
print ("signup fail");
}else{
print ("signup success");
}
});
});
}else{
print ("login success");
}
});
We are using ViPER Guestbook in our websites and getting following error messages:
[20-Jun-2015 12:01:40 UTC] PHP Warning: preg_match(): No ending delimiter '/' found in /home/...../...../gb/index.php on line 277
[20-Jun-2015 12:01:40 UTC] PHP Warning: preg_match(): No ending delimiter '/' found in /home/....../...../gb/index.php on line 278
These lines are:
(!preg_match("/^".PFIX."CUSTOM",$_key)) &&
(!preg_match("/^".PFIX."RATING",$_key))) {
The full code is:
$_b = true;
foreach ($arg as $_key => $_val) {
if ((!in_array($_key,$_paramlist)) &&
(!preg_match("/^".PFIX."CUSTOM",$_key)) &&
(!preg_match("/^".PFIX."RATING",$_key))) {
if (is_array($_val)) {
foreach ($_val as $_inkey => $_inval) {
$_param .= "&".urlencode($_key)."[".
urlencode($_inkey)."]=".urlencode($_inval);
}
}
else {
$_param .= "&".urlencode($_key)."=".urlencode($_val);
}
}
elseif ($_key != PFIX."decode")
$_b = false;
}
Where should the ending delimiter '/' be in this code?
Please help.
Thanks.
Lakshmanan
Thanks for your help.
We have corrected the code to as follows:
(!preg_match("/^".PFIX."CUSTOM/",$_key)) &&
(!preg_match("/^".PFIX."RATING/",$_key))) {
and there is no error messages as of now.
Thanks,
Lakshmanan