Comments (4)
from drupal.
Fundamentally, this change makes sense to me! The code in the patch is actually from Drupal 7, in includes/json-encode.inc. I've made PR #56 which is working in my testing. Going to hold off for a bit to see if it can get a little more testing first.
from drupal.
I'm trying to reconcile these changes with Pressflow's changes to drupal_to_js().
You will have to address this conflict if you try to pull these changes into D6LTS Pressflow (it's a bit behind BTW)
Pressflow dropped all this custom code and just uses json_encode()
https://github.com/d6lts/pressflow/blob/master/includes/common.inc#L2563
function drupal_to_js($var) {
// json_encode() does not escape <, > and &, so we do it with str_replace()
return str_replace(array("<", ">", "&"), array('\u003c', '\u003e', '\u0026'), json_encode($var));
}
I've been using the Pressflow version for about a decade without issue.
The D7 code you refer to is actually a fallback to support PHP < 5.3
For PHP >= 5.3.0 D7's drupal_json_encode() actually just uses this:
// Encode <, >, ', &, and " using the json_encode() options parameter.
return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
D8's version drop's the fallback logic and only uses the json_encode() logic.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Serialization%21Json.php/function/Json%3A%3Aencode/8.2.x
Differences:
The D7/8 version encodes ' and " characters where the Pressflow version does not.
The D7 fallback (and this current D6LTS version) encodes the following characters, where the D7/8 version leaves them un-encoded (but properly escaped):
"\", "\b", "\t", "\n", "\f", "\r", "/",
Is PHP < 5.3 support still a requirement for D6LTS?
If not, then it seems like we should probably just adopt the D7/8 json_encode() logic (which is similar, but an improvement to the version in Pressflow).
from drupal.
Is PHP < 5.3 support still a requirement for D6LTS?
Unfortunately, yes, we officially support PHP 5.2 and even have a couple stubborn customers that are still using it.
I believe Pressflow is PHP 5.3+ anyway, so I think it'd be fine if Pressflow didn't merge these changes and stuck with what it already has.
Also, I could see an argument for having D6LTS also check for PHP >=5.3 and using json_encode()
- if someone made a PR for that, there's a strong chance it'd go in.
from drupal.
Related Issues (20)
- substr() in database.inc HOT 2
- session_destroy(): Session callback expects true/false return value
- Typo in exclude HOT 1
- Bug: double prefixing with db_prefix array HOT 5
- One more theme.inc change HOT 6
- I broke my d6 site HOT 1
- replace ereg_replace and other removed functions HOT 2
- CHANGELOG.txt not updated since 6.52 HOT 1
- 6.58 update issue HOT 13
- MySQL 5.7 support? HOT 4
- Workaround for multi-byte characters HOT 4
- Drush 8.x does not work for some commands like `cc all` HOT 1
- Expectations with postgresql 12? HOT 1
- XSS Vulnerability - 1 HOT 2
- XSS Vulnerability - 2 HOT 3
- Regex in .htaccess to protect files and directories from prying eyes seems to have a typo HOT 1
- Any hope for php 8? HOT 27
- Website for d6lts org info points to spam
- Apache update causes Drupal URLs with spaces and other special characters to fail HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drupal.