1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-28 14:30:51 +00:00

Xomw: Add wfUrlencode

This commit is contained in:
gnosygnu 2017-02-25 18:06:47 -05:00
parent 4781529d12
commit 2b2f93b766
3 changed files with 903 additions and 917 deletions

View File

@ -60,19 +60,6 @@ public class Gfo_url_encoder_ {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.N)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Plus);
}
public static Gfo_url_encoder_mkr New__php_urlencode() {
// REF: http://php.net/manual/en/function.urlencode.php;
// "Returns a String in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs"
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Plus);
}
public static Gfo_url_encoder_mkr New__php_rawurlencode() {
// REF: http://php.net/manual/en/function.rawurlencode.php
// "Returns a String in which all non-alphanumeric characters except -_.~ have been replaced with a percent (%) sign followed by two hex digits. "
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__same__many(Byte_ascii.Tilde)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Plus);
}
private static Gfo_url_encoder_mkr New__http_url_ttl() {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y);
}
@ -103,6 +90,31 @@ public class Gfo_url_encoder_ {
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline)
;
}
public static Gfo_url_encoder_mkr New__php_urlencode() {
// REF: http://php.net/manual/en/function.urlencode.php;
// "Returns a String in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs"
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Plus);
}
public static Gfo_url_encoder_mkr New__wfUrlencode() {
// REF: GlobalFunctions.php|wfUrlencode
// same as php_urlencode, but do not encode ";:@$!*(),/~"
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Plus)
.Init__same__many
( Byte_ascii.Semic, Byte_ascii.At, Byte_ascii.Dollar, Byte_ascii.Bang, Byte_ascii.Star
, Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Comma, Byte_ascii.Slash
, Byte_ascii.Tilde
, Byte_ascii.Colon // NOTE: MW doesn't unescape colon if IIS. However, all of WMF servers run on non-IIS boxes, so include this;
);
}
public static Gfo_url_encoder_mkr New__php_rawurlencode() {
// REF: http://php.net/manual/en/function.rawurlencode.php
// "Returns a String in which all non-alphanumeric characters except -_.~ have been replaced with a percent (%) sign followed by two hex digits. "
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__same__many(Byte_ascii.Tilde)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Plus);
}
public static final Gfo_url_encoder
Id = Gfo_url_encoder_.New__html_id().Make()
, Href = Gfo_url_encoder_.New__html_href_mw(Bool_.Y).Make()
@ -116,5 +128,6 @@ public class Gfo_url_encoder_ {
, Mw_ttl = Gfo_url_encoder_.New__mw_ttl().Make()
, Php_urlencode = Gfo_url_encoder_.New__php_urlencode().Make()
, Php_rawurlencode = Gfo_url_encoder_.New__php_rawurlencode().Make()
, Mw_wfUrlencode = Gfo_url_encoder_.New__wfUrlencode().Make()
;
}

View File

@ -50,8 +50,8 @@ public class XomwTitle {
/** @var String Text form (spaces not underscores) of the main part */
private byte[] mTextform = Bry_.Empty;
// /** @var String URL-encoded form of the main part */
// public $mUrlform = Bry_.Empty;
/** @var String URL-encoded form of the main part */
private byte[] mUrlform = Bry_.Empty;
/** @var String Main part with underscores */
// XO: EX: "Help_talk:A_b" . "A_b"
@ -878,14 +878,14 @@ public class XomwTitle {
return this.mTextform;
}
// /**
// * Get the URL-encoded form of the main part
// *
// * @return String Main part of the title, URL-encoded
// */
// public function getPartialURL() {
// return this.mUrlform;
// }
/**
* Get the URL-encoded form of the main part
*
* @return String Main part of the title, URL-encoded
*/
public byte[] getPartialURL() {
return this.mUrlform;
}
/**
* Get the main part with underscores
@ -3376,7 +3376,7 @@ public class XomwTitle {
this.mUserCaseDBKey = parts.user_case_dbkey;
this.mDbkeyform = parts.dbkey;
// this.mUrlform = wfUrlencode(this.mDbkeyform);
this.mUrlform = XomwGlobalFunctions.wfUrlencode(this.mDbkeyform);
this.mTextform = XophpString.strtr(this.mDbkeyform, Byte_ascii.Underline, Byte_ascii.Space);
// We already know that some pages won't be in the database!
@ -4828,12 +4828,12 @@ public class XomwTitle {
// 'mDefaultNamespace',
// ];
// }
//
// public function __wakeup() {
// this.mArticleID = (this.mNamespace >= 0) ? -1 : 0;
// this.mUrlform = wfUrlencode(this.mDbkeyform);
// this.mTextform = strtr(this.mDbkeyform, '_', ' ');
// }
// public function __wakeup() {
// this.mArticleID = (this.mNamespace >= 0) ? -1 : 0;
// this.mUrlform = wfUrlencode(this.mDbkeyform);
// this.mTextform = strtr(this.mDbkeyform, '_', ' ');
// }
private static final byte[] Bry__wgArticlePath__wiki = Bry_.new_a7("/wiki/");
// REF.MW: DefaultSettings.php