I got a really strange issue that I can't solve, can anyone please suggest a solution? thank you in advance :)
I want to pass a complete url to a script, the script will check the url and do a meta refresh to redirect to it, so assume my script is goto.php and I want it redirect to:
http://www.google.com/?name=david¶m=gender
So I enter this in my browser:
www.mydomain.com/goto.php?u=http%3A%2F%2Fwww.google.com%2F%3Fname%3Ddavid%26param%3Dgender
But my goto.php script get:
http://www.google.com/?name=davidĀ¶m=gender
As you can see, the "&" is missed, here is the code of my goto.php:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>checking</title>
<meta name="robots" content="noindex,nofollow" />
</head>
<body>
<?php echo $_GET ['u'];?>
</body>
</html>
although if I add
<meta http-equiv="refresh" content="0;url=<?php echo $_GET ['u'];?>" />
it works in some browser, but in some other browser, it won't work, because the $_GET['u'] didn't return a valid url.
Thank you once more for any suggestion.
Looks like you have an issue with charset encoding/decoding. Whats the output of your "php -i"?
edit
I just gave it another try and your script is fine. The issue is that your URL is not escaped for HTML. If you look at the source of your page, then you will realize that everything looks fine.
You must escape all ampersands (&) before you output to HTML. Use htmlspecialchars() or htmlentities() for that.
http://php.net/manual/en/function.htmlspecialchars.php
<?php echo htmlspecialchars($_GET['u']); ?>
Please change the line
<?php echo $_GET['u']; ?>
to the following line
<?php echo urldecode($_GET['u']); ?>
Related
I am looking to use the source code of an email which has the desired template that i need in the Microsoft Graph API.
The standard format for this looks like so:
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "HTML",
"content": "The new cafeteria is open."
},
The sourcecodes template that i am looking to use already has contentType etc within the code.I have tried removing contentType and content and just having the source code within the body but this still does not work. Below is start of the source code that i am looking to use:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[if !mso]>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="http://www.opusenergy.com/wp-content/uploads/2016/03/Favicon-150x150.png" />
<title>Opus</title>
<!--[if (gte mso 9)|(IE)]>
<style type="text/css">
table {border-collapse: collapse !important;}
</style>
Any help will be greatly appreciated, Thank you.
The above payload is not what Graph API looks for. You need to specify the payload for the create message API call and the structure is given in the Graph API document. Still if you want to customize, you can do it, by making sure to modify/customize in-lines with Microsoft Graph API recommendation. Say i will put the HTML content inside the content of the Graph API call, specify the contenttype as HTML. This is the way i would start testing it make sure whether it's working or still i need to modify so that the message can show correctly in Outlook or not.
You tried the above recommendation and confirmed that it works.
If i want to send out email/template then i would first make sure it works in Word/Outlook; so that you can validate the HTML/CSS tags are working in, as i know that not all tags are not supported. Please keep this best practice and plan it accordingly. It will help you to build the template as you wish and you're guaranteed that the Outlook will show-up them as well.
im trying to upload to this form with vb.net
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/css/login.css">
</head><meta charset="UTF-8">
<form method="post" action="/addData">
<input type="text" name="id"/>
<textarea name="data"></textarea>
<input type="submit" name="add" value="go"/>
</form>
and here is the vb code
Dim data2 As New System.Collections.Specialized.NameValueCollection()
data2.Add("id", TextBox1.Text)
data2.Add("data", TextBox2.Text)
data2.Add("add", "go")
Dim client As New System.Net.WebClient
client.UploadValues("link", data2)
any idea what im doing wrong here?
im always getting error 404, but it's not right.
because i did simple check by showing msgbox displaying the page source.
and it worked
We can't say much from that (at least I can't).
What you should do is inspect the POST request you send (via your regular browser) that way you will know what you need to send.
For example, here is how the POST request looks like for posting this answer.
qualityBanWarningShown=false&referrer=https%3A%2F%2Fstackoverflow.com%2Fquestions%2Ftagged%2Fvb.net&post-text=We+can't+say+much+from+that+(at+least+I+can't).%0D%0A%0D%0AWhat+you+should+do+is+inspect+the+POST+request+you+send+(via+your+regular+browser)+that+way+you+will+know+what+you+need+to+send.&fkey=<something>&author=&i1l=<something>
The form sends its POST to /addData, which means you need to do so as well. If you're trying to POST to the page which's code you've shown above it won't work.
The URL starts with a slash (/), meaning addData is located in the website's root directory. Thus you should send your POST to: http://www.website.com/addData (or https:// depending on what the website is using).
I am pretty new to nightwatchjs and encountering a strange behaviour when I tried to assert simple text in a single dom
Same assertion method and one works but another doesn't
// This works
client.expect.element('#MenuToggle').text.to.contain('Menu');
// This doesn't work and it always returns empty "" string
client.expect.element('#BackToMain').text.to.contain('Back to main');
The code given in your question is correct and should work... To help you with debugging, please try to run the following minimal working example:
HTML (index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nightwatch</title>
</head>
<body>
Menu
Back to main
</body>
</html>
JavaScript (test.js)
module.exports = {
'Test': function (browser) {
browser.url('http://localhost:8000/index.html'); // Change this if needed
browser.expect.element('#MenuToggle').text.to.contain('Menu');
browser.expect.element('#BackToMain').text.to.contain('Back to main');
browser.end();
}
};
Command
nightwatch -t tests/test.js
If it does not work:
Check if your environment is OK (it works with Node v7.7.4 + Nightwatch v0.9.14).
Edit your question to add more code.
I'm a noob trying to learn Codeception with the Selenium WebServer and have come across a problem I can't seem to find an answer to. I'm writing a super basic test that ensure the data passed in a from in index.php, is the same on another page, toupper.php.
This is my index.php:
<?php $something = "Can you see me?"; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Convert Me!</title>
</head>
<body>
<h1>Convert Me!</h1>
<p>
<?php echo $something; ?>
</p>
<form action="toupper.php" method="post" id="post_form">
<label for="string">Convert to Uppercase:</label>
<input type="text" name="my_string" id="string">
<input id="submit" type="submit" name="submitButton" value="Convert">
</form>
</body>
</html>
This is my toupper.php:
<?php
$message = (!empty($_POST['my_string'])) ? strtoupper($_POST['my_string']) : "No string entered";
?>
<!DOCTYPE html>
<html>
<head>
<title>To Upper!</title>
</head>
<body>
<h1>To Upper!</h1>
<p class="message"><?php echo $message; ?></p>
<p>Back to form.</p>
</body>
</html>
I've created a simple testsuite:
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('ensure Toupper form works');
$I->amOnPage('index.php');
$I->see('Can you see me?');
$I->fillField('my_string', 'convert me to uppercase');
$I->click('Convert');
$I->amOnSubdomain('toupper.php');
$I->see('CONVERT ME TO UPPERCASE');
Now, whenever I run the test, the test passes, but when I run the exact test again with the same data, it fails. And I'm not using a database.
This is the error I get:
Scenario --
I am on page "index.php"
I see "Can you see me?"
I fill field "my_string","convert me to uppercase"
I click "Convert"
I am on subdomain "toupper.php"
I see "CONVERT ME TO UPPERCASE"
FAIL
--------------------------------------------------------------
Time: 2.59 seconds, Memory: 8.00MB
There was 1 failure:
---------
1) ToupperCept: Ensure toupper form works
Test tests/acceptance/ToupperCept.php
Step See "CONVERT ME TO UPPERCASE"
Fail Failed asserting that /toupper.php
-->
--> contains "convert me to uppercase".
Scenario Steps:
6. $I->see("CONVERT ME TO UPPERCASE")
5. $I->amOnSubdomain("toupper.php")
4. $I->click("Convert")
3. $I->fillField("my_string","convert me to uppercase")
2. $I->see("Can you see me?")
1. $I->amOnPage("index.php")
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
Can someone point me in the right direction as to how to solve this? I appreciate it!
UPDATE
Upon messing around with the test, that when I write an assertion looking for the text in uppercase on toupper.php, EX) $I->see('SOMETHING'); , the test fails. It seems that if the test fails at some point, all other assertions fail. Even when I comment out the failed assertion, all previous assertion fail upon running the test again. So confused!!
UPDATE2
Sorry for the multiple updates, but messing around a bit more, I switched browsers for webdriver from firefox to chrome. All my tests are passing flawlessly everytime. Strange that only having issues with firefox.
Try inserting a $I->pauseExecution(); in your test code just before the failing line. Then you can easily see what is happening in the browser window just before the fail. Possibly you are having an issue with Firefox retaining data in the form.
I want to use CActiveForm's AjaxValidation.
My layout view file was like this before enabling AjaxValidation:
<html lang="tr-TR" dir="ltr">
<head>
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.js"></script>
</head>
As you see i'm calling jquery framework on my layout page (because i'm using on every page).
And i decided to use CActiveForm's ajax validation. Firstly enable enableAjaxValidation while calling it:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'otel-form',
'enableAjaxValidation'=>true,
)); ?>
And then uncomment this on my controller
$this->performAjaxValidation($model);
But i got $(...).yiiactiveform is not a function error. When i check source code of page :
As you see, one more jquery library included, too. So there are 2 jquery files on page. Because of this i'm getting error. Next i put something like this for disabling jquery.
Yii::app()->clientscript->scriptMap['jquery.js'] = false;
Now jquery is loading only once. But this result is :
<html lang="tr-TR" dir="ltr">
<head>
<script type="text/javascript" src="/istanbulcityhotels/assets/cb2686c8/jquery.yiiactiveform.js"></script>
<script src="/istanbulcityhotels/js/jquery.js"></script>
</head>
jquery.yiiactiveform.js calling BEFORE jquery.js . It should called AFTER jquery.js.
It confused a bit. What should i do?
ADDITIONAL
Yes, i read this question because titles' are really similar, but question isnot same.
Thank you.
You should not be including jQuery manually from your layout. Instead of doing this, include it from within your Controller base class:
public function init() {
Yii::app()->clientScript->registerCoreScript('jquery');
}
Don't forget to call parent::init() from within your concrete controllers.
It seems CActiveForm inserts the scripts before the title tag using CClientScript::POS_HEAD constant. So a workaround is to add this code
<?php
$cs=Yii::app()->clientScript;
$cs->scriptMap=array(
'jquery.js'=>false
);?>
to the top of the main layout file in order stop it from loading jquery, then put the title tag after you load your jquery file
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.js"></script>
This way jquery.yiiactiveform.js will be loaded right after jquery.
just put your own jquery on tag title,
just like this:
<script src="/istanbulcityhotels/js/jquery.js"></script>
<title>your title</title>