Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb| /** | |
| * 随机字符串 | |
| */ | |
| private static final char[] CHARS = new char[] {'F', 'L', 'G', 'W', '5', 'X', 'C', '3', | |
| '9', 'Z', 'M', '6', '7', 'Y', 'R', 'T', '2', 'H', 'S', '8', 'D', 'V', 'E', 'J', '4', 'K', | |
| 'Q', 'P', 'U', 'A', 'N', 'B'}; | |
| private final static int CHARS_LENGTH = 32; | |
| /** | |
| * 邀请码长度 |
| document.addEventListener("DOMContentLoaded", function() { | |
| FastClick.attach(document.body); | |
| parent.registerBridge && parent.registerBridge(); | |
| var g = "//" + window.OFO_ENV.API_HOST + "/ofo/Api/"; | |
| var Q = function() { | |
| if (window.location.host == "common.ofo.so") { | |
| return "//" + "product.api.ofo.com" + "/ofo/Api/" | |
| } else { | |
| return g | |
| } |
| #!/usr/bin/env python | |
| #coding=utf-8 | |
| # | |
| # Generate a list of dnsmasq rules with ipset for gfwlist | |
| # | |
| # Copyright (C) 2014 http://www.shuyz.com | |
| # Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules | |
| import urllib2 | |
| import re |