@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace Remarkup calls to `PhabricatorHash::digest()` with SHA256

Summary:
Ref T12509. Many of the calls to HMAC+SHA1 are just to compute cachekeys for remarkup objects.

Make these use HMAC+SHA256 instead. There is no downside to swapping these since they just cause a cache miss in the worst case.

I also plan to get rid of `PhabricatorMarkupInterface` eventually, but this doesn't go that far.

Test Plan: Browsed some different types of documents (tasks, legalpad documents, phame blogs / posts, pholio mocks, etc).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12509

Differential Revision: https://secure.phabricator.com/D17631

+41 -32
+2 -3
src/applications/calendar/storage/PhabricatorCalendarEvent.php
··· 1182 1182 * @task markup 1183 1183 */ 1184 1184 public function getMarkupFieldKey($field) { 1185 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 1186 - $id = $this->getID(); 1187 - return "calendar:T{$id}:{$field}:{$hash}"; 1185 + $content = $this->getMarkupText($field); 1186 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 1188 1187 } 1189 1188 1190 1189
+2 -2
src/applications/differential/storage/DifferentialInlineComment.php
··· 260 260 261 261 262 262 public function getMarkupFieldKey($field) { 263 - // We can't use ID because synthetic comments don't have it. 264 - return 'DI:'.PhabricatorHash::digest($this->getContent()); 263 + $content = $this->getMarkupText($field); 264 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 265 265 } 266 266 267 267 public function newMarkupEngine($field) {
+2 -2
src/applications/legalpad/storage/LegalpadDocumentBody.php
··· 39 39 40 40 41 41 public function getMarkupFieldKey($field) { 42 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 43 - return 'LEGB:'.$hash; 42 + $content = $this->getMarkupText($field); 43 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 44 44 } 45 45 46 46 public function newMarkupEngine($field) {
+2 -3
src/applications/maniphest/storage/ManiphestTask.php
··· 301 301 * @task markup 302 302 */ 303 303 public function getMarkupFieldKey($field) { 304 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 305 - $id = $this->getID(); 306 - return "maniphest:T{$id}:{$field}:{$hash}"; 304 + $content = $this->getMarkupText($field); 305 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 307 306 } 308 307 309 308
+2 -2
src/applications/phame/storage/PhameBlog.php
··· 289 289 290 290 291 291 public function getMarkupFieldKey($field) { 292 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 293 - return $this->getPHID().':'.$field.':'.$hash; 292 + $content = $this->getMarkupText($field); 293 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 294 294 } 295 295 296 296
+2 -2
src/applications/phame/storage/PhamePost.php
··· 241 241 242 242 243 243 public function getMarkupFieldKey($field) { 244 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 245 - return $this->getPHID().':'.$field.':'.$hash; 244 + $content = $this->getMarkupText($field); 245 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 246 246 } 247 247 248 248 public function newMarkupEngine($field) {
+2 -2
src/applications/pholio/storage/PholioImage.php
··· 84 84 85 85 86 86 public function getMarkupFieldKey($field) { 87 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 88 - return 'M:'.$hash; 87 + $content = $this->getMarkupText($field); 88 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 89 89 } 90 90 91 91 public function newMarkupEngine($field) {
+2 -2
src/applications/pholio/storage/PholioMock.php
··· 217 217 218 218 219 219 public function getMarkupFieldKey($field) { 220 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 221 - return 'M:'.$hash; 220 + $content = $this->getMarkupText($field); 221 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 222 222 } 223 223 224 224 public function newMarkupEngine($field) {
+2 -6
src/applications/phriction/storage/PhrictionContent.php
··· 68 68 * @task markup 69 69 */ 70 70 public function getMarkupFieldKey($field) { 71 - if ($this->shouldUseMarkupCache($field)) { 72 - $id = $this->getID(); 73 - } else { 74 - $id = PhabricatorHash::digest($this->getMarkupText($field)); 75 - } 76 - return "phriction:{$field}:{$id}"; 71 + $content = $this->getMarkupText($field); 72 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 77 73 } 78 74 79 75
+2 -3
src/applications/ponder/storage/PonderAnswer.php
··· 136 136 // Markup interface 137 137 138 138 public function getMarkupFieldKey($field) { 139 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 140 - $id = $this->getID(); 141 - return "ponder:A{$id}:{$field}:{$hash}"; 139 + $content = $this->getMarkupText($field); 140 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 142 141 } 143 142 144 143 public function getMarkupText($field) {
+2 -3
src/applications/ponder/storage/PonderQuestion.php
··· 155 155 // Markup interface 156 156 157 157 public function getMarkupFieldKey($field) { 158 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 159 - $id = $this->getID(); 160 - return "ponder:Q{$id}:{$field}:{$hash}"; 158 + $content = $this->getMarkupText($field); 159 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 161 160 } 162 161 163 162 public function getMarkupText($field) {
+4 -2
src/applications/releeph/field/specification/ReleephFieldSpecification.php
··· 236 236 } 237 237 238 238 final public function getMarkupFieldKey($field) { 239 - return sprintf( 239 + $content = sprintf( 240 240 '%s:%s:%s:%s', 241 241 $this->getReleephRequest()->getPHID(), 242 242 $this->getStorageKey(), 243 243 $field, 244 - PhabricatorHash::digest($this->getMarkupText($field))); 244 + $this->getMarkupText($field)); 245 + 246 + return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); 245 247 } 246 248 247 249 final public function newMarkupEngine($field) {
+15
src/infrastructure/markup/PhabricatorMarkupEngine.php
··· 694 694 ->execute(); 695 695 } 696 696 697 + public static function digestRemarkupContent($object, $content) { 698 + $parts = array(); 699 + $parts[] = get_class($object); 700 + 701 + if ($object instanceof PhabricatorLiskDAO) { 702 + $parts[] = $object->getID(); 703 + } 704 + 705 + $parts[] = $content; 706 + 707 + $message = implode("\n", $parts); 708 + 709 + return PhabricatorHash::digestWithNamedKey($message, 'remarkup'); 710 + } 711 + 697 712 }